All functions Mac OS X Windows Crossplatform Components New in version: 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 2.0
Component: Applescript
Mac OS X: Works
Windows: Does nothing
MBS( "Applescript.Run" ; Script Text )
Parameter | Description | Example value |
---|---|---|
Script Text | This is the text of the script to run | "3 + 4" |
The function compiles the text passed to it and runs it. Any Result returned by the AppleScript is returned as the result of the calculation. This is similar to the Script Results that were introduced in FileMaker 8.0. This is much easier then using Applescript.Compile, Applescript.Execute and Applescript.Close
Trigger a FileMaker Script Using OS Scripting
Let(
[
// --- the name of the script to run ------------------
ScriptName = "Triggered Script";
FileName = Get(FileName);
//------------------------------------------------------------
//--- don't need to edit anything below this line --------
Applescript = "do script " & Quote(ScriptName);
VBScriptText =
"FUNCTION DoFMSCript(FileName, ScriptName)" & "¶" &
"Set fmApp = CreateObject(\"FMPro.Application\")" & "¶" &
"fmApp.Visible = True" & "¶" &
"Set fmDocs = fmApp.Documents" & "¶" &
"For Each fmDoc In fmDocs" & "¶" &
"If InStr(LCase(fmDoc.fullname), LCase(FileName)) > 0 Then" & "¶" &
" fmDoc.dofmscript (ScriptName)" & "¶" &
"End If" & "¶" &
"Next" & "¶" &
"END FUNCTION";
ScriptID = MBS("WindowsScript.Create");
lang= MBS("WindowsScript.SetLanguage"; ScriptID; "VBScript");
addcode = MBS("WindowsScript.AddCode"; ScriptID; VBScriptText)
];
Case(
Get ( SystemPlatform ) = 1;
// Mac OSX Case
MBS(
"Applescript.Run";
Applescript
);
// Windows Case
MBS("WindowsScript.ExecuteFunction";ScriptID; "DoFMScript";FileName; ScriptName) &
MBS("WindowsScript.Close"; ScriptID)
)
)
Create A Folder
Let(
[
/*-----------------PARAMETERS--------------------*/
folderName = "My New Folder";
scriptText =
"set folder_name to " & Quote(folderName) & "¶" &
"tell application " & Quote("Finder") & "¶" &
" set f to make new folder at desktop" & "¶" &
" set the name of f to folder_name" & "¶" &
"end tell"
];
/*-------------------FUNCTION----------------------*/
MBS(
"Applescript.Run";
scriptText
)
)
/*------------------------------------------/
Creates a folder called "My New Folder on the users desktop
*/
Get Names From Address Book
Let(
[
/*-----------------PARAMETERS--------------------*/
scriptText =
"tell application \"Address Book\"" & "¶" &
" set the_list to \"\"" & "¶" &
" set person_list to the name of every person" & "¶" &
" repeat with this_name in person_list" & "¶" &
" set the_list to the_list & this_name & return" & "¶" &
" end repeat" & "¶" &
"end tell"
];
/*-------------------FUNCTION----------------------*/
MBS(
"Applescript.Run";
scriptText
)
)
/*------------------------------------------/
Creates a folder called "My New Folder on the users desktop
*/
Trigger A FileMaker Script (Custom Function)
MBS_TriggerScript ( "Triggered Script" ; Get ( FileName ) )
Custom Function Definition
/*###############################################
MBS_TriggerScript
created 10/26/06, by Todd Geist, todd@geistinteractive.com
Parameters: theScriptName, theFileName
Dependancies: MBS FileMaker Plug-in.
Notes: Uses VBScript and Applescript to run a script
################################################*/
Let(
[
Applescript = "do script " & Quote(theScriptName);
VBScriptText =
"FUNCTION DoFMSCript(FileName, ScriptName)" & "¶" &
"Set fmApp = CreateObject(\"FMPro.Application\")" & "¶" &
"fmApp.Visible = True" & "¶" &
"Set fmDocs = fmApp.Documents" & "¶" &
"For Each fmDoc In fmDocs" & "¶" &
"If InStr(LCase(fmDoc.fullname), LCase(FileName)) > 0 Then" & "¶" &
" fmDoc.dofmscript (ScriptName)" & "¶" &
"End If" & "¶" &
"Next" & "¶" &
"END FUNCTION";
ScriptID = MBS("WindowsScript.Create");
lang= MBS("WindowsScript.SetLanguage"; ScriptID; "VBScript");
addcode = MBS("WindowsScript.AddCode"; ScriptID; VBScriptText)
];
Case(
Get ( SystemPlatform ) = 1;
// Mac OSX Case
MBS(
"Applescript.Run";
Applescript
);
// Windows Case
MBS("WindowsScript.ExecuteFunction";ScriptID; "DoFMScript";theFileName; theScriptName) &
MBS("WindowsScript.Close"; ScriptID)
)
Feedback: Report problem or ask question.