Jump to content
Server Maintenance This Week. ×

How do I *use* a Custom Function with FM8.5?lmy


This topic is 6421 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Dear All

I understand from my reading of the documentation that you need to own a copy of Filemaker Advanced to *create* a Custom Function, and I only have plain old ordinary Filemaker 8.5.

But I have found in BrianDunning.com a Custom Function I would like to use. Can I use it without owning FMAdvanced, and if so how??? The page it is on (http://www.briandunning.com/cf/59) shows the formula with a button marked "Select All" and the instruction to "copy & paste into FileMaker Advanced", which obviously I cannot do!

Can CFunctions be downloaded as a type of pre-compiled plugin? And if so, how do I add it to my database? Excuse my ignorance. :

Link to comment
Share on other sites

Hi Philip:

Excuse my ignorance. :)

No dispensation is necessary; you raise a good question for folks building their FileMaker skills.

Often the calculation embodied in a Custom Function can serve as the basis of a calculation field ... sometimes by copying the CF's calculation in its entirety and pasting it into the field definition of a calculation field. At other times, some revision of the CF's calculation is required ... it just varies depending on the CF. In fact, I use this technique simply to test how the author's calculation works before I decide whether to add the custom function to my file.

I'm glad you provided the URL for the custom function you're eying ... Link. In order for its calculation to know "where to look," you'll first need ...

• a field named "TStampBegin" defined as Type "Timestamp" and

• a field named "TStampEnd" defined as Type "Timestamp" and

• a field named "Format" defined as Type "Text" and for which you can create a Value List with the following values: String, Days, Hours, Minutes, Seconds.

Next, you'll need a calculation field named something like "ElapsedTime" with the following attributes ...

• "Calculation results in Text"

• "Do not evaluate if all referenced fields are empty" is Checked

• Let the Storage default to "Indexing ... None ... Automatically create indexes as needed." (The subject of Stored vs Unstored has numerous considerations. If you don't happen to yet know your way around the topic, it's a key concept you'll want to study.)

Copy the custom function from Brian Dunning's site, then paste it into your ElapsedTime calculation. Click "OK" to save the changes, then you can start experimenting with the fields on your layout. Tip ... with your cursor in your Timestamp fields, select "Current Time" from the "Insert" menu. You can edit those timestamps to see different results.

Let us know how it turns out!

N.B.: I went through all the steps above to test it in one of my files. Worked pretty well except for the results when the Format was set to "Seconds."

Link to comment
Share on other sites

Thanks for that explanation. I did as you said, and it worked :)

At least, it did for output format of "String" which is the only type I need, as I want to use it to display a "5 minutes later" or "x days, x minutes, x seconds later" message.

But I wasn't happy with the way it gave results like " 1 day, 0 hours, 0 minutes, 2 seconds" so I added a nested set of "If's" like this to remove the 'zero' entries:

If ( Days = 0 ; "" ;

If (Days = 1 ; Days & " day, " ; Days & " days, " ))

&

If ( Hours = 0 ; "" ;

If ( Hours = 1 ; Hours & " hour, " ; Hours & " hours, " ))

&

If ( Minutes = 0 ; "" ;

If ( Minutes = 1 ; Minutes & " minute, " ; Minutes & " minutes, " ))

&

If ( Seconds = 0 ; "" ;

If ( Seconds = 1 ; Seconds & " second, " ; Seconds & " seconds" ))

&

" later"

Now I really like it!!

But then I tested what would happen if TStampBegin got a value that was later than TStampEnd, and it gave me an ugly result with 'minus' values in it! I think it should really say: "x days/hours/minutes/seconds earlier."

I think I can make it do that by adding an extra "If" clause testing if TStampBegin is later than TStampEnd, and if so calculating the positive value of the difference but changing "later" to "earlier".

However (and here comes my next question -- : -- I think I can visualize how to do that by repeating the whole function in a second "If" clause, but is there a way of introducing a "variable" into the calculation so that I can have just one calculation as at present, but choose at the end which ending to use ("earlier" or "later").

I imagine the 'brute force' method of nesting the whole thing twice will work, but it would be much neater (and would add to my store of knowledge!) to know if it can be kept more elegant.

Once again many thanks for your help. PHILIP CAPLAN

Link to comment
Share on other sites

You might shorten that a bit using this method:

If ( Days ; Days & " day" & If ( Days > 1 ; "s" ) & ", " ) &

If ( Hours ; Hours & " hour" & If ( Hours > 1 ; "s" ) & ", " ) &

If ( Minutes ; Minutes & " minute" & If ( Minutes > 1 ; "s" ) & ", " ) &

If ( Seconds ; Seconds & " second" & If ( Seconds > 1 ; "s" ) )

) &

" later"

Edited by Guest
Link to comment
Share on other sites

Hi LaRetta,

My apologies to you but this is the only way I can ask you a question. There is no way of getting in contact with other members on this site that I know of.

My question for you is :)

You had worked on HCFA form previously on other projects.

Any way of sharing and helping me with some questions ?

Dis you ever find a product to translate HCFA to text or X12 format for medical billing ?

Again I apologize for just throughing my question here !

send me a line please : [email protected]

Link to comment
Share on other sites

In future, you can always Private Message a member (I'm unsure if that's available to all Registered Members but I believe so) but yes, I will follow up with you. I'm on a crunch so give me a day or so when I can fit it in. :wink2:

L

Link to comment
Share on other sites

Rearding conversion of Custom functions in a standard calc field, rather than replacing the variables in each and every place, you might consider using a let function instead i.e.:)

Let([Days = YourDaysField ; Hours = YourHoursField ; Mintues = YourMinutesField ; Seconds = YourSecondsField];

If ( Days = 0 ; "" ;

If (Days = 1 ; Days & " day, " ; Days & " days, " ))

&

If ( Hours = 0 ; "" ;

If ( Hours = 1 ; Hours & " hour, " ; Hours & " hours, " ))

&

If ( Minutes = 0 ; "" ;

If ( Minutes = 1 ; Minutes & " minute, " ; Minutes & " minutes, " ))

&

If ( Seconds = 0 ; "" ;

If ( Seconds = 1 ; Seconds & " second, " ; Seconds & " seconds" ))

&

" later"

)

Link to comment
Share on other sites

This topic is 6421 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.