Example of a JScript ) L5 `% n7 d& V. t# q
var vbOKCancel = 1; $ H6 s( P* c4 I
var vbCancel = 2; , X, b1 `$ C8 N- p& S
var vbInformation = 64; 0 X* k8 K8 Z+ u0 c7 ^! R- D( \- H
var Finished=false;
2 T$ k' c) _5 _: |" Y( u
9 ]7 K' `8 Q$ I2 Vvar WSHShell = new ActiveXObject("WScript.Shell");
1 T% T; G3 m7 x3 j1 w) a * C l' R) H' Q
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); - S+ Y8 B2 F; z0 I' [# M; P2 z/ u
4 q$ Z* F$ \$ \& k& asimple.SetLicenseType("Runtime");
' `3 t7 i' k) x- X- c7 o
+ Q$ o+ T8 e' A- N1 H) @try
% Y1 C. Q, ~9 M6 D/ o x( a( U{ # m& V0 @% S8 _ l& e
// Enter the path to a model file! 6 K! T! ^, A2 E7 z2 {2 W- e
simple.LoadModel("C:\\Models\\Test.spp");
: `3 W/ @2 L3 B: Z}
3 s1 u: X3 C5 Z2 r# qcatch (e) 0 M* a& V/ ]+ ~ J# u; E
{ ' U5 {, U% q' g- n6 O
WScript.Echo("Could not load Model!"); 7 F9 ~3 v0 s. @% |. T# b9 ?' h# v
WScript.Quit(); 2 |1 R" p& Z7 M, Y8 N: j6 y
}
+ t# Y/ k5 z- ~3 R
9 t/ r J$ n/ c: A* Y, t+ y' vtry 3 O9 N. k$ A' W/ M
{ , B0 F/ o9 d/ e, l
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { . C, o7 G& Y% k1 k- t3 j2 C
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& q1 ?- p4 S$ Y if (r == vbCancel)
1 ~+ a7 R* S3 x" H( b @ {
% [6 I# s# G! {! k$ S simple.CloseModel(); 2 _+ ^& Z1 v V0 ~& V2 {
WScript.Quit();
$ V4 {+ s/ I8 w' W } 7 A! Z% D i5 i' s/ N
}
/ j/ F) @$ L' W! T9 Q* ^
0 a! e1 f# Q$ Hsimple.StartSimulation(".Models.Frame.EventController");
7 q' U B/ U" P( u " \: A7 F) |1 z9 f1 u
if (simple.IsSimulationRunning()) 2 y, D1 v" ~9 G! q3 Z! e
WScript.Echo("Simulation is running!"); , R ~( d \1 \7 B
, |* s# }$ D! I) O1 w. K! ^// Wait until simulation is finished 4 P. M4 u0 ?! S! Y4 I: M
while (!Finished) WScript.Sleep(2000); ) x3 R% X# B8 u$ b2 [ a
8 I7 i: L7 t% l3 u5 l6 ?) O9 i
simple.CloseModel(); ~: q* q5 P' H& J; B! k
simple.Quit(); & l3 X3 n4 l' G" S( b4 q
WScript.Quit(); * K0 Z/ d" x& z- k4 M) d" S# F
% z! l7 g% Q- a; ^6 m6 K8 }
) Z H. @$ `7 \7 t& H
function RemoteControl_SimulationFinished()
/ Q* k( P2 Y% s/ |2 @# k{
; I6 [- K- C0 h) N2 n WScript.Echo("Simulation Finished!"); |