Example of a JScript
& a7 l3 f/ C, S' |5 q0 a8 avar vbOKCancel = 1; e: U4 t0 @- h' V3 A
var vbCancel = 2;
3 N; `$ M8 \# s: p6 V; E. Gvar vbInformation = 64;
, `/ x% W+ |* X0 i/ a0 ovar Finished=false;
/ _9 M. Y, c$ t0 {: I * n4 ^6 h) j4 f; m/ G6 B
var WSHShell = new ActiveXObject("WScript.Shell");
1 [) Y9 _6 Z0 e" c1 b7 C
1 r" a4 a4 W V- n) c3 mvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
9 @6 g* o& ?0 @" K, O! P+ E" e1 o
- W* m& I" c8 e- O1 t& Hsimple.SetLicenseType("Runtime"); . ^) v. S8 w- b/ A# ?9 t
) v2 Y3 r1 Z) u, P$ `: ^
try
" h8 y4 v" \- O% O9 F8 K# Q& c{
0 Y. s k) ?: f; I // Enter the path to a model file!
' Y9 N/ I, |+ `! f& w8 J simple.LoadModel("C:\\Models\\Test.spp");
% w! ?) `6 v/ u; P" b* v} ( D) d& T" Q+ ~8 F# a; ~: s, N$ M2 h
catch (e)
1 P0 d. c2 A% p8 u5 \' }" H{
' a; C' Y& o+ M, y1 D% E WScript.Echo("Could not load Model!");
! o5 {; d' H, T7 s' ? |( Q& l$ o WScript.Quit();
* C3 H; w7 ?( v2 b7 [} . O( o4 K7 a; d& _
3 Y: R8 w; A+ c$ z8 P. G3 R% dtry 2 X& h) U3 ]7 M
{ " G% Q* v( x# E+ B
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { . y7 M7 ?( K7 _% E
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 1 z- ?8 k- S0 i5 |4 j- M3 `8 x4 O% c
if (r == vbCancel)
+ `4 J" N9 C+ s" ?) ]2 f { $ X: ?- B9 O# d7 s% i+ W
simple.CloseModel();
2 l0 v' N( ]& z; E, n2 P WScript.Quit(); R5 F/ d# t( n+ m/ ~
} . i2 P# N+ z; Z0 S0 `! w# M
}
; h* ^2 X/ E, x
6 x7 u% X0 k n( ~0 vsimple.StartSimulation(".Models.Frame.EventController"); 0 ^ p! v) U, F4 B H+ I
! A( B1 G& X8 c) h9 q6 x( V4 rif (simple.IsSimulationRunning()) + E8 H$ T; T/ g3 s1 f
WScript.Echo("Simulation is running!"); 5 b/ g K) p1 l% t% d8 F1 E J3 Q
! [ L% J# U8 O7 j
// Wait until simulation is finished p) R& y0 i4 O- U$ c4 s4 O5 P" l
while (!Finished) WScript.Sleep(2000);
, T& R" K1 s) c* P 3 U3 @: E0 f1 S9 F
simple.CloseModel();
8 k1 t2 ~% A0 n. nsimple.Quit(); + d& n! {% q) x. y8 g3 Q
WScript.Quit(); $ s! L @8 b4 v; \; q4 R- ^
! Q r+ D; ~# N- |- m1 b * H+ [2 L- Y! N* y: V% u4 l
function RemoteControl_SimulationFinished() 6 Y. T0 f7 g4 d" o
{
' q! k$ s" {% n6 C( R WScript.Echo("Simulation Finished!"); |