Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3   9.4   9.5    Statistic  

SyntaxColoring.AddContextMenuCommand

Adds a new command for contextual menu.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
SyntaxColoring 9.5 Yes No No No No
MBS( "SyntaxColoring.AddContextMenuCommand"; Title; Expression; needSelection )   More

Parameters

Parameter Description Example value
Title The title for the menu command.
If multi line, we build submenus based on the path descripted.
"MyCommands¶Hello"
Expression The expression to evaluate in FileMaker when menu command is choosen.
needSelection Whether to enable only if selection is present.
0: always on
1: need no row selected
2: need exactly one row selected
3: need one or more rows selected
4: need all rows selected
0

Result

Returns OK or error.

Description

Adds a new command for contextual menu.
Given commands are added to contextual menu in Script Workspace when right clicking on script steps.
Commands are stored in preferences file and can be removed via SyntaxColoring.ClearContextMenuCommands function.

If you use Clipboard.GetFileMakerData and Clipboard.SetFileMakerData functions, you can get the XML for the current step. You may want to use Menubar.RunMenuCommand to run cut/copy/paste/delete commands from the FileMaker menu with the respective command IDs: 57635 for cut, 57634 for copy, 57637 for paste, 57632 for delete and 57642 for select all.

Possible uses include commands
  • to add new script steps.
  • to check scripts for errors.
  • to search and replace things
  • to add common snippets, possibly using SQL or text file functions to read the XML for them.
  • to pass script steps as XML to external tools.
Use SyntaxColoring.RemoveContextMenuCommand to remove one or SyntaxColoring.ClearContextMenuCommands to clear all.

Examples

Add a greeting command:

MBS( "SyntaxColoring.AddContextMenuCommand"; "Greeting"; "MBS(\"Msgbox\"; \"Hello World\")"; 0 )

Add a rename command for variable:

MBS( "SyntaxColoring.AddContextMenuCommand";
"Rename $I to $counter";
"Let ([ r = MBS( \"Menubar.RunMenuCommand\"; 57634 /* copy */ ); xml = MBS( \"Clipboard.GetFileMakerData\"; \"ScriptStep\" ); xml = Substitute ( xml; \"$i\"; \"$counter\"); r = MBS( \"Clipboard.SetFileMakerData\"; \"ScriptStep\"; xml ); r = MBS( \"Menubar.RunMenuCommand\"; 57637 /* paste */ ) ]; \"\" )"; 0 )

Add an insert loop command:

MBS( "SyntaxColoring.AddContextMenuCommand";
"Insert For Loop";
"Let ([
xml = \"<fmxmlsnippet type=\\\"FMObjectList\\\"><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"><Text>loop counting up from 1 to $count</Text></Step><Step enable=\\\"True\\\" id=\\\"141\\\" name=\\\"Set Variable\\\"><Value><Calculation><![CDATA[\\\"/* add count here */\\\"]]></Calculation></Value><Repetition><Calculation><![CDATA[1]]></Calculation></Repetition><Name>$count</Name></Step><Step enable=\\\"True\\\" id=\\\"141\\\" name=\\\"Set Variable\\\"><Value><Calculation><![CDATA[1]]></Calculation></Value><Repetition><Calculation><![CDATA[1]]></Calculation></Repetition><Name>$index</Name></Step><Step enable=\\\"True\\\" id=\\\"68\\\" name=\\\"If\\\"><Calculation><![CDATA[$index ≤ $count]]></Calculation></Step><Step enable=\\\"True\\\" id=\\\"71\\\" name=\\\"Loop\\\"></Step><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"><Text>your script steps here</Text></Step><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"></Step><Step enable=\\\"True\\\" id=\\\"89\\\" name=\\\"# (comment)\\\"><Text>next</Text></Step><Step enable=\\\"True\\\" id=\\\"141\\\" name=\\\"Set Variable\\\"><Value><Calculation><![CDATA[$index + 1]]></Calculation></Value><Repetition><Calculation><![CDATA[1]]></Calculation></Repetition><Name>$index</Name></Step><Step enable=\\\"True\\\" id=\\\"72\\\" name=\\\"Exit Loop If\\\"><Calculation><![CDATA[$index > $count]]></Calculation></Step><Step enable=\\\"True\\\" id=\\\"73\\\" name=\\\"End Loop\\\"></Step><Step enable=\\\"True\\\" id=\\\"70\\\" name=\\\"End If\\\"></Step></fmxmlsnippet>\";
r = MBS( \"Clipboard.SetFileMakerData\"; \"ScriptStep\"; xml );
r = MBS( \"Menubar.RunMenuCommand\"; 57637 /* paste */ )
]; \"\" )"; 0 )

See also

Blog Entries

Created 18th October 2019, last changed 11st November 2019


StoreRegistration   -   SyntaxColoring.AddTag

Feedback: Report problem or ask question.




Links
MBS Xojo Chart Plugins