Example of a JScript
1 ~4 |' I$ a( Q0 X. q' E6 C$ i& W& cvar vbOKCancel = 1; . G, _$ _, q5 j0 {' ^
var vbCancel = 2; - F: ^( P- M$ s! d' b
var vbInformation = 64;
# ^* w+ P/ w4 mvar Finished=false;
! |8 y% L0 x2 c, I& C / d$ b: g; C4 g8 P* h4 n
var WSHShell = new ActiveXObject("WScript.Shell");
% u; O$ `9 j) ^4 q, j 5 g0 @- w! J4 Q. x
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ; l/ h& G5 W. A& R
: [% ~. R: r* h* `6 Ksimple.SetLicenseType("Runtime"); 6 l; x9 h5 l% f. v" z" q
9 v0 @8 _! q9 s' n+ q* C* Rtry 9 I" D* u2 ?' v- Z" E9 A% c
{
: X1 n% E6 K# w+ \* K* N // Enter the path to a model file!
; C3 Q' F- c3 h% ]. b* C; U simple.LoadModel("C:\\Models\\Test.spp");
8 c/ g# U0 a! P} # D. Y/ A) h u3 s( r; t! b1 M
catch (e) ' _# p4 v. i! a
{ 0 A9 k! @; m3 s5 f0 a
WScript.Echo("Could not load Model!"); ! L( l4 Y/ G# E- r% \
WScript.Quit();
5 Q5 R* [6 ?* h2 o0 e}
: r! {% u, F2 c" P. f G, X. f / g& I, I7 l, O' E
try / T. ?+ ?3 L' s" M$ c0 t1 e5 a' |' Y
{
; K& Z1 r a/ `3 ~; \ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
/ `* U" I3 y" l! ^ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); : y2 I! e# Z% W: {! Y+ ?- `9 ?
if (r == vbCancel)
! R& [/ _' O Y- k, K { 5 d- \3 m( Y- E' T/ D
simple.CloseModel(); / l2 c% w3 V. ^+ {+ X n2 R+ ~
WScript.Quit(); & @8 H6 d5 g$ |
} 1 W$ u9 d7 P7 Q1 B' L
}
$ [# i( q0 z2 B! x: V6 a2 t# G ?; n: J2 k1 f. P8 W) r
simple.StartSimulation(".Models.Frame.EventController"); 1 M. k& b: R6 Q) Z
) C* J& Y% s! Q) wif (simple.IsSimulationRunning()) " Q: ^, ]; C2 H7 {4 b, a- u
WScript.Echo("Simulation is running!");
0 d6 d' X8 `7 W" H' B: S
: N2 r0 J% Z) ^( O3 H// Wait until simulation is finished
' `' P9 x' l3 U I6 G8 Kwhile (!Finished) WScript.Sleep(2000); 2 R3 L: f0 ^0 ^" H
, g! E2 W; W+ r" _$ V0 g
simple.CloseModel();
$ }+ l+ {5 ^6 O# bsimple.Quit();
! r4 A- U/ U( L8 P: E6 kWScript.Quit();
1 n0 V' }4 @. l ( Z, f8 l0 M1 U. f
! R9 s" d" \4 r# w9 i5 a
function RemoteControl_SimulationFinished()
1 ?% E- |, C# Y& Y4 _" E0 \{
^0 T, K0 y/ {/ U4 N$ C) ` WScript.Echo("Simulation Finished!"); |