Example of a JScript
- Y/ V* F; x- yvar vbOKCancel = 1;
: i" @' _3 b% I/ G3 nvar vbCancel = 2;
' d/ e8 j/ o! {) svar vbInformation = 64; + I8 u, D( }, \* P
var Finished=false; - A; e G G+ Q/ u" ~, n
: D- \9 E) |' Z* X) \( wvar WSHShell = new ActiveXObject("WScript.Shell"); % R: A E- D6 L6 h/ ] _: M; @
) @- Y3 X% }) k& {
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); " d6 x! ~0 {6 z( ]: G% @
2 M( O& \ [9 o& K2 D3 j5 }) P [# rsimple.SetLicenseType("Runtime"); 1 c- B( ~+ g0 C
G) k& ^' {6 i, h Mtry
3 f. g& E* t4 z" w2 _3 ~, l9 ^{ 6 p* |+ _* }; L4 S4 m& ^
// Enter the path to a model file! $ K5 K* L; H, U; C
simple.LoadModel("C:\\Models\\Test.spp");
6 F$ ~# [5 ]% A0 S} & t3 s" c. e# n5 n% b7 x$ y
catch (e) ) A1 u7 J! k& k
{
* S3 P# N# Q7 I+ Z WScript.Echo("Could not load Model!"); # Z9 m1 o$ ~& B& n0 e
WScript.Quit();
4 v6 k% g/ d2 {; y}
# [& S h" j8 t) [+ `8 _/ f
; W) n6 X8 ~) ctry
# d& p+ _) r, w- O/ D{
' ^7 x0 @) r6 V5 ? simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 9 t4 x# B9 }1 ~4 C/ v5 y4 J
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 8 c% F; l e `. o, Q8 a0 |
if (r == vbCancel)
8 ?( o0 C1 B8 J/ _2 \; n { ! O% J+ B8 B; m* g- a! Y( M/ X
simple.CloseModel(); 9 J7 k2 U3 E6 T1 f6 l+ Q
WScript.Quit(); ! S, Y3 J" i2 g) j
} 9 t3 a; G8 \ Z3 c6 |: K
} ) |3 Z0 R, m2 x; j" l, R2 ~
; E& X* I4 h. x, ?% m$ Zsimple.StartSimulation(".Models.Frame.EventController"); & \8 H4 H% L/ C; q
( F) L& `/ @5 M- gif (simple.IsSimulationRunning())
" A% v/ h6 r* f8 U% s# M WScript.Echo("Simulation is running!"); 3 z2 |1 ^5 |3 F+ R8 X; D, W( R: V
$ q8 R' R( g5 Z7 v# S
// Wait until simulation is finished
# U; C0 l- y9 |2 {while (!Finished) WScript.Sleep(2000); / [' s7 V- f# Y1 q
" B) ?8 u6 D& t6 t F( q" b" a2 R
simple.CloseModel(); ; Z% y" d0 N/ s v& C: A
simple.Quit(); 4 C# V' F' |* h, {
WScript.Quit(); p8 `. X- s/ q, U. n
- `# D } K4 j
+ z# X8 {1 g$ }* W; g. o k8 Hfunction RemoteControl_SimulationFinished()
" k( m# }' t- b1 m. {{
/ Q' x* @# e G, k& j/ A WScript.Echo("Simulation Finished!"); |