Example of a JScript
' z; d/ z6 y; svar vbOKCancel = 1; 9 N0 l5 w9 U, t
var vbCancel = 2;
! M6 u4 h3 \' Y- p' o A9 Kvar vbInformation = 64; 8 B9 I8 F' m# X3 g/ H$ u: H( B
var Finished=false;
1 _$ n; j9 R9 ?! s & ` G, j5 H& g3 n( B: f- f
var WSHShell = new ActiveXObject("WScript.Shell");
9 _* L9 y8 y2 M$ m# j
" s5 v4 q8 S& f" Zvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
3 r8 x$ Q# f: N g7 G& H$ s! d+ p3 l b0 v
simple.SetLicenseType("Runtime"); & o- i. B0 i' o: a/ i5 {- P
/ @- ?" l8 a4 [* Ntry % t# Q( ]. U) J" Y, g
{ / k" q5 m1 ]7 S9 w
// Enter the path to a model file!
4 G1 @; m7 x8 v, W simple.LoadModel("C:\\Models\\Test.spp");
8 J( \1 ~1 Y8 L. Y" Q} _& J! S p# r
catch (e) 5 w1 D; F) T' E/ d8 X+ T& b1 U: [
{ 6 k% `5 q* R1 p! u7 D$ v+ ~
WScript.Echo("Could not load Model!");
2 E/ J; ]" C3 A2 x7 Y2 ~# R; k WScript.Quit();
6 W4 w6 M0 z4 R5 [3 f}
; \3 R; R, Q! k2 L) }1 u+ W& k; V . v2 ~8 x# o5 w j& E
try & d8 s+ g+ f' x( J! w
{
& H0 Q. @1 w6 k+ S N simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { / _& Z' R- s9 x5 ?9 W
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& C+ o: ^6 V" O& @ if (r == vbCancel)
( b ? L$ T7 V {
$ w9 t4 W3 C2 L# q# I {0 ]" r9 U& p simple.CloseModel(); & J" D% a# z5 H. _' y: s
WScript.Quit(); % y" U" _( K0 D9 r6 y
}
& v" {4 L1 h2 g7 h8 ~ |} 6 _7 X# W$ h, E2 {8 \
7 ]9 A9 `6 [0 Z. i! h. O
simple.StartSimulation(".Models.Frame.EventController");
0 d: {& g3 N6 D
* h9 p; m+ B7 ?' |' x$ vif (simple.IsSimulationRunning())
5 v Q- |5 V1 D WScript.Echo("Simulation is running!");
5 U5 {' ^! {" A+ x
* l8 V; L& x" O" Q+ J3 J* Q5 X// Wait until simulation is finished
5 j/ A1 ]% L' n. h( x7 a$ qwhile (!Finished) WScript.Sleep(2000);
" t% A; p6 z, [3 t8 _# W4 L
8 o u8 X" F& l& nsimple.CloseModel(); " h& B( ^0 A. W
simple.Quit(); 2 Z! {. r$ s3 s* [
WScript.Quit();
3 c/ [9 U- h' B( O2 M2 A" U ; w( _" }& I! _: d7 S) Z
P; K5 p" f( D. @/ i. S+ L2 zfunction RemoteControl_SimulationFinished()
' E( X7 V w: `3 W( ~% j{
7 \: j" G9 A n5 J% O! H WScript.Echo("Simulation Finished!"); |