Jump to content

Debugging custom functions


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

Recommended Posts

Hi Guys,

I have been looking for an easy way to debug CF's, and stumbled upon CF Explorer, but that was developed for FMv7 and hasn't been updated afaik. The original website isn't there any more.

Are there any tools/plugins that can be used to debug CF's? Similar to the standard debugger?

 

Thanks!

Link to comment
Share on other sites

You are correct about the file not having been upgraded to FileMaker Pro 12 +, however it still works for a lot of the Custom Functions being posted there, and the site is still there,  FM Functions. The owner has taken it down a couple of times because of lack of activity. i.e. the more that use it, the more likely it will not stop being a resource.

There are other ways of testing.

I use the Data Viewer, and testing files.

Edited by Lee Smith
added a few more comments about the site.
Link to comment
Share on other sites

How would you use the data viewer to debug CF's? You can't step through the various commands using the data viewer that I know.

What I do at the moment is use a result var in the CF and add data from variables that I use in the CF as the CF progresses so that I have an idea how data is manipulated or handled. I then populate a Global var with the CF result var as one of the last actions in the CF. That works, but is a little convoluted to setup.

For instance I have the following CF:

/* GetKeyValue( keylist; key; separator )
   keylist   = list of keys and values separated by "separator".
   key       = key to look for and to return the value of.
   separator = the character that separates the key from the value. Usually "=" but can be anything.

   result in the CF is used to capture debugging information. If the global variable $$Debug is true, then "result" will be copied into $$DebugResult.
 */

If( Position( keylist; key & separator; 1; 1 );
    Let([
         result   = "Passed parameters:¶keylist: \"" & keylist & "\"¶key: \"" & key & "\"¶separator: \"" & separator & "\"¶";
         key      = Lower( ";" & key );
         keylist  = ";" & keylist & ";";
         result   = result & "¶key: \"" & key & "\"¶keylist: \"" & keylist & "\"";
         pos      = Position( Lower( keylist ); key & separator; 1; 1);
         keyvalue = Right( keylist; Length( keylist) - Pos );
         result   = result & "¶position of \";\" leading the key: \"" & pos & "\"¶keyvalue: \"" & keyvalue & "\"";
         pos      = Position( keyvalue; ";"; 1; 1);
         keyvalue = If( Pos; Left( keyvalue; Pos - 1 ); keyvalue);
         result   = result & "¶position of \";\" following the value: \"" & pos & "\"¶keyvalue: \"" & keyvalue & "\"";
         pos      = Position( keyvalue; separator; 1; 1);
         value    = Right( keyvalue; Length( keyvalue) - Pos );
         result   = result & "¶value: \"" & value & "\"";

         $$DebugResult = If( $$Debug; result; "" )
        ];
        If( not IsEmpty( value ); value; "" )
        )
    )

I call that CF with a ";" delimited list of keywords/values like "var1=value1;var2=value2;var3=value3" and use the CF to extract the value of the key I'm after.

The Global var ends up with the following content:

Passed parameters:
keylist: "var1=value1;var2=value2;var3=value3"
key: "var2"
separator: "="

key: ";var2"
keylist: ";var1=value1;var2=value2;var3=value3;"
position of ";" leading the key: "13"
keyvalue: "var2=value2;var3=value3;"
position of ";" following the value: "12"
keyvalue: "var2=value2"
value: "value2"

But I don't like the added complexity of all the result lines and was hoping someone would have a better idea.

Edited by OlgerDiekstra
correction
Link to comment
Share on other sites

I don't think I've had a big need for that level of debugging.  If it is not a recursive CF then you can just use the data viewer to simulate it and tweak it so that it works correctly, then put it in a CF.

Recursive CFs are more difficulat since you can not simulate those in the data viewer.

Link to comment
Share on other sites

This topic is 1816 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
 Share

  • Who Viewed the Topic

    1 member has viewed this topic:
    comment 
×
×
  • Create New...

Important Information

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