Example of a JScript
4 K" M! h6 U9 X" n% v4 svar vbOKCancel = 1;
, j9 O8 F. y1 Y, w$ @" Cvar vbCancel = 2;
4 e! h# T3 J7 g: tvar vbInformation = 64;
* }) Y' m! c( O( [( ^1 k. \7 Fvar Finished=false; : f6 P _* v: y" P* K
% i$ s' g6 B8 p4 x! ]
var WSHShell = new ActiveXObject("WScript.Shell"); 6 h: U6 ]; z! Y4 R4 C
) |2 m( {8 h) U5 E4 F$ v2 L* m
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
8 q4 a/ o6 d7 U! |+ W# ?3 S - l) [; K$ h7 J _$ L
simple.SetLicenseType("Runtime"); ! M8 Q, H+ Y$ ^: g/ A, T
* l% M8 D7 }2 J& ?7 ?9 k
try
* Y7 U0 E1 Q' f: U- G. W{
+ U" X; ^0 p$ J+ P // Enter the path to a model file!
# T0 @: S; h! `7 k. D7 j- p simple.LoadModel("C:\\Models\\Test.spp");
1 ]. d; K) Z! `, {9 _! a) R1 c} # k, N( N* T' d6 t# H7 T$ t
catch (e) : A# c- e& m7 O5 ^8 X- g. q; r. |
{
1 n. T2 h0 O1 ^+ S# I WScript.Echo("Could not load Model!"); 1 V5 |( `% u; E) ^
WScript.Quit(); : }; n0 b0 S/ C) g
}
. ^! I- p$ o! @" `5 @8 h
. V B, R1 p( E8 O5 \5 ttry
6 L4 [; V4 m. l/ u7 \{
* {8 \3 C- Q: @. | simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
# }( p2 P; ]: i7 _ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); * t' S, {: @2 u H- U$ t( |
if (r == vbCancel) 6 S* T# C1 ^- \1 a
{
+ O4 ^2 m' R0 L% U7 w simple.CloseModel();
0 X. x3 |4 p I9 ~( H9 i WScript.Quit(); 0 S: [8 b* ~ J M, g
} . h% k! n; b- c% [5 c% d/ M0 Y- Z
} 4 I. ?5 ?) t, y, ^2 C0 D
0 E+ _/ v* p8 X$ n( P& G: R: D* Isimple.StartSimulation(".Models.Frame.EventController");
6 M# ]% x( K/ v# z
' I; w( U& D {" o- f$ dif (simple.IsSimulationRunning())
" z# ~8 ^3 J4 j0 o8 v' `: ]4 U WScript.Echo("Simulation is running!");
5 q6 i" b. O1 m( K% R* K) h & e0 X% o _; E! A0 Z% l
// Wait until simulation is finished
' }: i! A! ^- c! N2 Cwhile (!Finished) WScript.Sleep(2000);
8 z; s1 K) j- ^' J * l3 O$ N- h" t6 |0 S* {8 t) B5 i7 u
simple.CloseModel();
% O$ r* U' n6 L! u- B* H/ d" Rsimple.Quit(); 8 ~2 d4 Y; l S) m
WScript.Quit(); 3 E- f1 F+ I1 q" q$ L0 P0 o
: Z3 m; C" o9 k6 Y# }2 u6 K
! h1 {& {. z0 Afunction RemoteControl_SimulationFinished() 5 K# c7 I2 [" ]2 b
{ # ?- W) T5 w5 B4 l4 t' e
WScript.Echo("Simulation Finished!"); |