« xDev Magazine 21.6 Is… | Home | Performance improveme… »

Comment links with goto and script scheme

This may change how you write scripts. Your longer scripts may now have an index on top with goto: URLs jumping to specific lines. The goto:start and goto:end links may help to jump to start or end of the script. And script: links may jump to a different script.

 

Let's start with script links. You put in the script name after the script: prefix. The plugin will read the name, decode percent escaped sequences and looks for a script in same file with the given name to show it. If you have special characters in the script name, please use GetAsURLEncoded() function in FileMaker to get the URL encoded properly, e.g. with %20 for spaces. This may look like this in the script:

 

# We open the database connection in the Connect to database script 

# See also script:Close%20database 🌍 

#

Perform Script [ Specified: From list ; “Connect to database” ; Parameter:    ]

#

Set Variable [ $result; Value: Get(ScriptResult) ]

 

 

And you may include goto: URLs in the comments. For example you can just put in a number to jump to a line. This allows you to jump from the top of the script right into the action below without scrolling yourself. Just like you would do an index page in a big PDF to jump to the right page. You can also use goto:end to jump to the end of the script. For performance reasons you may want to collect comments on the bottom of the script. Jumping from top to the bottom would scroll all the way down to show these comments. You can do a goto:start to jump back to the first line.

 

# Description Test Script

# Author Christian

# History on the bottom goto:end 🌍 

Allow User Abort [ Off ]

Set Error Capture [ On ]

Set Variable [ $param ; Value: Get(ScriptParameter) ] 

# do something useful

# loop counting up from 1 to $count

Set Variable [ $count ; Value: 100 ] 

Set Variable [ $index ; Value: 1 ] 

If [ $index ≤ $count ] 

Loop [ Flush: Always ]

# your script steps here

# next

Set Variable [ $index ; Value: $index + 1 ] 

Exit Loop If [ $index > $count ] 

End Loop

End If

Set Variable [ $result ; Value: "" ] 

Exit Script [ Text Result: $result ] 

# back to top: goto:start 🌍 

#  Version History

# Modified 30th October 2023 by Christian

# * added more comments

# * added loop in line 15   goto:15 🌍 

# Created 30th October 2023 by Christian

# * first version

 

If you start using these links in your scripts, you may enjoy easier navigation on macOS in the Script Workspace. Please try soon with the next pre-release of 13.5.

You can enable comment links via preferences dialog or with the SyntaxColoring.CommentLinks.SetEnabled function.

02 11 23 - 08:50