Example of a JScript
2 Y; a0 f$ k& i8 S% i3 m9 ~5 R- y' nvar vbOKCancel = 1; 7 m c4 D z6 O
var vbCancel = 2;
" S; g: U" _! T2 X' Hvar vbInformation = 64; % z: L$ _; a% C% `
var Finished=false; 9 l' _6 J. [3 L7 e! p
3 J" p5 m- A7 |" b# svar WSHShell = new ActiveXObject("WScript.Shell");
1 J! O% N" r7 F; W* ~
8 d1 ~3 F5 P+ T0 {1 Bvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 8 `3 T2 G+ ?/ t. s4 c
1 A4 Z' H. L1 _7 Ysimple.SetLicenseType("Runtime");
6 B4 W) |; d6 n& e
8 n/ m( E' T# J+ v- s( e) g, ktry . y7 C+ C" J' A, W' }% Z8 X
{
- X7 v+ Z/ ]; F' ^7 l4 S // Enter the path to a model file!
3 v# U. p+ n& c" | simple.LoadModel("C:\\Models\\Test.spp"); ; C& `8 G2 o. ~# v) E
} 6 J& q) O3 ~1 F. x5 f# Y' l9 K
catch (e)
0 C' D7 ?& Q0 W8 Q( ]' b{ 7 n. i" _) o9 D8 R% S
WScript.Echo("Could not load Model!");
: a/ I6 X1 ^5 }: ]3 l- i) q: w- @ _ WScript.Quit();
* e5 T! `) Z) g, j}
# e* j" c; r$ M% m4 s$ L: ~, z3 _ 3 b4 m+ G4 j) v! {+ V6 e
try
* I! L) y) L; [8 b! q{ : g# P6 F+ b! B) [
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
9 C$ W2 S' J) y+ x r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
3 h s8 u9 J2 u1 u+ v if (r == vbCancel) & L4 I' `) R$ R
{ , A& z1 }5 R( F& r: d- Q8 k' H+ j
simple.CloseModel(); % B8 R( C# K% i+ a
WScript.Quit();
9 x. V0 [6 X/ S }
' i3 T8 K( J; q- a}
0 V. K5 W8 ]$ ^/ P+ @) Q, L- H `) t6 v
4 o' I# j- S/ C8 ` Y+ w" f; t gsimple.StartSimulation(".Models.Frame.EventController");
' H- S8 Y; w; y" c9 o! c. t! a ' q6 X$ ?- r) i* s+ V
if (simple.IsSimulationRunning())
v; ]) a, c7 ?5 ^6 L3 G8 V WScript.Echo("Simulation is running!"); - K' R1 \: R& i3 o# r: ^ `& k
j2 _1 Z6 v2 E$ R! C7 x
// Wait until simulation is finished
9 H, B0 L; f( K9 [while (!Finished) WScript.Sleep(2000);
* {; c$ B; d3 }5 o& k$ ?4 [2 U; h
1 ~) y1 g, L& N/ t. |7 ~simple.CloseModel();
- A2 c- |; Q" }7 ]9 k2 Z( s# ^simple.Quit(); ! ]+ d! B$ o# `( S
WScript.Quit();
9 h: O1 x& |: M1 ~' Q* {& B
8 N3 D: I9 ]" c- j+ M. [ 5 I9 s; W: y) J9 N# U4 Z# T0 h
function RemoteControl_SimulationFinished() ; z2 z' G: E4 I5 K2 H
{ * O/ q7 q5 {; s5 n- D* _! t/ y
WScript.Echo("Simulation Finished!"); |