Jump to content
Sign in to follow this  
trevorg

#Comment Interferes with Script - Bug?

Recommended Posts

Hi Everyone,

I just ran into an unexpected behavior. I had the following simple script: (Condensed for typing sake)

Set Error Capture ON

Loop

Set Field (some data in the record)

Go To Record/Request/Page[Exit after last, Next]

#Look for records that fail required value validations

IF[status(CurrentError) = 509]

#Must revert the record to allow the script to continue.

Revert Record/Request [No dialogue]

End If

End Loop

Using Developer 5.5 and the Debug Script mode, when stepping through each Script Step FileMaker fails to capture the 509 error because the comment is in-between the action that causes the error and the IF that catches the error. If I move the comment out from in-between the two, it does capture the error.

Wow. A comment shouldn't mess up a script.

Share this post


Link to post
Share on other sites

Yep, I agree - but FMP doesn't hold on to the generated error code for more than the next step, so its important to place your If[status(CurrentError)] step immediately after the action which could case the error.

If you don't want to do this, then you should store the error number in a global field and then check for it in a later script step by running the If step on the contents of the global field.

Share this post


Link to post
Share on other sites

Trevorg is right...only the very lame-brained would execute a comment line in a debugger. I have never seen that done in any language/compiler environment (over 30 year of experience). Comments are universally ignored by the compiler or interpreter.

Share this post


Link to post
Share on other sites

It is not so much that the comment is executed or that the debugger forgets the error code, it is that EVERY SINGLE SCRIPT STEP sets the error code. And there is only 1 error code register available to the Status ( CurrentError ) command. So the error code from the Find Script is valid only until the next line where another error code is set.

If you want to make the error code more persistant then use a global field. Personally I use global repeating fields for storing error codes. I then have a layout which shows them all as well as what each of them stores. This way I can see error results from my last find, import, export, sort, or whatever other function I want.

Share this post


Link to post
Share on other sites

Kurt: What you say is certainly true . My point is that a comment is not and should not be an executable script step. In fact, a nice change would be for them to let us put a # in front of any line to prevent its execution, rather than having to move the statement to the bottom of the script following an Exit or Halt or deleting the statement.

Share this post


Link to post
Share on other sites

I would love to have the ability to put a "#" in front of a step to prevent it from executing.

Kinda like the "rem" in DOS- for those you old enough to remember....

Jack

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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