Add a search and replace command for FileMaker Script Workspace
MBS( "SyntaxColoring.AddContextMenuCommand";
"Search and Replace";
"Let ([
/* ask for search text via dialog */
ResetResult = MBS( \"Dialog.Reset\" );
ClearResult = MBS( \"Dialog.ClearFields\" );
MessageResult = MBS( \"Dialog.SetMessage\"; \"Search and replace in script:\" );
InfoResult = MBS( \"Dialog.SetInformativeText\"; \"Search text can include XML tags.\" );
Field1Result = MBS( \"Dialog.AddField\"; \"Search for:\" );
Field2Result = MBS( \"Dialog.AddField\"; \"Replace with:\" );
Button1Result = MBS( \"Dialog.SetDefaultButton\"; \"Replace\");
Button2Result = MBS( \"Dialog.SetAlternateButton\"; \"Cancel\");
DialogResult = MBS( \"Dialog.Run\" );
SearchText = MBS( \"Dialog.GetFieldText\"; 0 );
ReplaceText = MBS( \"Dialog.GetFieldText\"; 1 );
/* do replace */
r = If(DialogResult = \"Replace\"; Let([
/* copy script steps */
r = MBS( \"Menubar.RunMenuCommand\"; 57634 );
/* get XML from clipboard */
xml = MBS( \"Clipboard.GetFileMakerData\"; \"ScriptStep\" );
/* search and replace */
xml = Substitute ( xml; SearchText; ReplaceText);
/* put XML back on clipboard */
r = MBS( \"Clipboard.SetFileMakerData\"; \"ScriptStep\"; xml );
/* paste script steps */
r = MBS( \"Menubar.RunMenuCommand\"; 57637 )
]; 1))
];1)"; 3 )
Let ([
/* ask for search text via dialog */
ResetResult = MBS( "Dialog.Reset" );
ClearResult = MBS( "Dialog.ClearFields" );
MessageResult = MBS( "Dialog.SetMessage"; "Search and replace in script:" );
InfoResult = MBS( "Dialog.SetInformativeText"; "Search text can include XML tags." );
Field1Result = MBS( "Dialog.AddField"; "Search for:" );
Field2Result = MBS( "Dialog.AddField"; "Replace with:" );
Button1Result = MBS( "Dialog.SetDefaultButton"; "Replace");
Button2Result = MBS( "Dialog.SetAlternateButton"; "Cancel");
DialogResult = MBS( "Dialog.Run" );
SearchText = MBS( "Dialog.GetFieldText"; 0 );
ReplaceText = MBS( "Dialog.GetFieldText"; 1 );
/* do replace */
r = If(DialogResult = "Replace"; Let([
/* copy script steps */
r = MBS( "Menubar.RunMenuCommand"; 57634 );
/* get XML from clipboard */
xml = MBS( "Clipboard.GetFileMakerData"; "ScriptStep" );
/* search and replace */
xml = Substitute ( xml; SearchText; ReplaceText);
/* put XML back on clipboard */
r = MBS( "Clipboard.SetFileMakerData"; "ScriptStep"; xml );
/* paste script steps */
r = MBS( "Menubar.RunMenuCommand"; 57637 )
]; 1))