Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.5   7.0   7.1   7.2   7.3   7.4   7.5   8.0   8.1   8.2    Statistic  

WindowsScript.Create

Creates a Windows Script in memory.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
WindowsScript 1.1 No Yes Yes, Windows only No No

MBS( "WindowsScript.Create" )

Parameters

none

Description

Creates a Windows Script in memory.
Once the script is created you can add script code to by using the WindowsScript.AddCode function. The script is then executed using WindowScript.Run. The default language of a new script is Jscript. This can be changed by using the WindowsScript.SetLanguage function.

ScriptControl from Microsoft is 32-bit only. If you need 64-bit, please install a 64-bit alternative MSScript.ocx file.

Examples

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)

)
)

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)

)
)

Use JScript to Get System Date

Let(
[
JScriptText = "function TestDate(){var d =new Date();
return d.toGMTString();}";
scriptID = MBS("WindowsScript.Create");
SetLang = MBS("WindowsScript.SetLanguage";1;"JScript");
addcode = MBS("WindowsScript.AddCode";1;JScriptText);
theDate = MBS("WindowsScript.ExecuteFunction";1;"TestDate");
closeScript = MBS("WindowsScript.Close";1)

];

theDate

)

See also

Example Databases


WindowsScript.Close   -   WindowsScript.ErrorClear

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins