Example of a JScript " O+ Q6 b8 ?8 k' j9 h: [' D" Q5 Y" i
var vbOKCancel = 1; - X3 b# W% Z" D* b7 o
var vbCancel = 2;
% P; t+ w' F8 u- jvar vbInformation = 64; 6 `* R. f- d# P, o
var Finished=false; $ `, f- u2 O# s6 D" @1 @
. ]! R9 k9 n# p. N2 h( U
var WSHShell = new ActiveXObject("WScript.Shell"); + U, v3 I X5 ?' O
* I$ n; M8 U" K: V2 h" Qvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
* o+ z2 P/ A5 l; [8 a
v& M+ I3 q2 ~" h n. I1 @simple.SetLicenseType("Runtime");
: u4 j) N1 q3 Y6 f. F' S . a @3 m; G% A& c
try 3 e' R% g- w2 I% F
{
6 d. H& ?9 J, j& O) A( a' M // Enter the path to a model file!
: k9 ?) u; T) m; Q7 L7 ~" U" p% Z simple.LoadModel("C:\\Models\\Test.spp"); 5 Z" u6 w: x! Q3 T! M
}
2 Y7 v/ Z# U) B. i/ }8 T0 _catch (e)
. I2 A: N+ b7 a{
; x& D; Z* e$ l( n* K* l, [8 C WScript.Echo("Could not load Model!"); 3 w3 I: U& t# @6 M0 f& x# e/ ]
WScript.Quit(); . V! Q6 s) I, M6 ]. a
} + @5 n! k- A) h) v
5 t' S3 F& f# W {+ g
try 2 w. @2 L+ q9 l/ t4 @: M
{
8 q) B5 D- _ M+ e Q1 R( k simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
1 g8 J0 L6 R( h* T r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ' {- l, x* ~; f; D
if (r == vbCancel)
! J! b, f: @ \% z* ^/ Z7 r/ Q { ( o& M8 T8 E& T0 Y1 t, \
simple.CloseModel();
1 M2 a: c2 E N+ ~' W6 N WScript.Quit();
7 E. P0 a& s; q# ]9 ? }
( a9 A% j+ g: l( Q% g0 E} : y: Q: `% _7 a7 G
$ r/ N5 m1 `- Z' v' q+ `6 m0 {simple.StartSimulation(".Models.Frame.EventController");
5 y. }/ E2 i8 s2 q \4 } Y+ c
8 t, h) ?8 t- u, Dif (simple.IsSimulationRunning())
" N3 j8 |4 ?; ` WScript.Echo("Simulation is running!");
4 @4 N4 g n/ x 0 p! ?) e e. F) B2 D9 n# j$ v8 M
// Wait until simulation is finished 1 S% d. s+ P0 P' [& I
while (!Finished) WScript.Sleep(2000);
# n& H9 J+ |2 u3 O; S: Y0 F2 O7 Q . s1 s$ A' I/ l2 Q# P4 d
simple.CloseModel();
0 z& _ O1 W' J# N3 Dsimple.Quit(); 8 ?5 j: x/ D* V6 ?% i( |" H
WScript.Quit(); : s; F0 S0 o) P: C
' A. S5 M6 L- a" D$ R2 t8 S+ _ 2 d1 b7 a }" h0 ]$ W$ C o8 C2 j
function RemoteControl_SimulationFinished()
6 c6 e# t+ }# W; |$ ]{ ( H3 [! w; k3 m( ?- T! b& z$ I) X
WScript.Echo("Simulation Finished!"); |