Example of a JScript ' w; \' V/ Q: ?% Z- R( x2 [
var vbOKCancel = 1; 0 a/ x% g/ K' k* b/ o2 u. g( t0 s% `
var vbCancel = 2; . k1 m( C! ~" Q% H6 M
var vbInformation = 64;
8 H! u/ ^ f, N+ r+ nvar Finished=false; 5 Y) x4 E1 _1 K- `5 n
- d9 C$ a+ \3 {2 d7 g7 G
var WSHShell = new ActiveXObject("WScript.Shell");
7 d! t* B. S4 c; M3 s1 f' S ( A# l) P6 E. b8 P
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 3 F% K% N; `+ G, {8 t! t
2 v n% ?2 q& p) R psimple.SetLicenseType("Runtime"); 6 |- \* x* p! m6 r4 H6 I& F
9 e. s+ Z+ ^% ?8 g) ~' s
try , w5 k8 z5 K: D4 F2 H9 E# _) |( J F
{ 1 e& |0 p# F; j( [1 I
// Enter the path to a model file!
8 X v0 _. C# ]5 O% U& V0 d# i simple.LoadModel("C:\\Models\\Test.spp");
* o+ O9 r& P5 C6 ~1 W+ F- @% e4 m}
0 s& p% ~/ Y$ J% }5 z, Q5 ^- Mcatch (e)
' y2 N1 W0 w6 M3 F{
* D. Y# ~9 X9 Q% Y& y WScript.Echo("Could not load Model!");
1 L6 N6 L( e5 P6 v) d WScript.Quit();
9 v) z7 I! {6 b* z3 Y# c}
5 |! S" B# i& K# g2 n( n
" |1 q7 Y. F9 c( {1 s# ?try ( V" l: U' ^9 M( M! s+ C
{ j6 E) p6 d/ V5 Y- B
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
% k0 b0 H( b ~ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
e' a' e3 t/ t- Z4 `( } if (r == vbCancel) : q6 W' b/ F, z5 Q/ |
{ ) Y0 W3 V* {! E4 l8 w, R
simple.CloseModel(); . K8 z o5 s; i9 S
WScript.Quit();
7 I3 C' X" d5 d1 t } ( S: B& b3 W& k7 ?
}
+ L- b9 y+ _5 q: B2 k" \
! V1 z& b0 C9 d" U; C/ G" qsimple.StartSimulation(".Models.Frame.EventController"); 7 e3 e% j* H! r* p4 L
3 R5 r' I2 c7 v" P2 |# X3 Dif (simple.IsSimulationRunning()) % g* @/ Y. M5 Z4 S0 n
WScript.Echo("Simulation is running!");
. X0 H7 q+ `7 r* z: Y , r. L" q0 x8 ~6 Y9 g9 S
// Wait until simulation is finished
2 G- W# T2 A F J8 y7 x! owhile (!Finished) WScript.Sleep(2000); , j* j7 L. Z* @$ v6 q/ S+ a
" i6 Z _: E7 }3 f; k3 N+ Asimple.CloseModel(); & L( s- h- W J5 F- P# V
simple.Quit();
7 h% v; j) S* s+ I9 Y \: q( ]WScript.Quit();
4 M% C& ^, W7 ~2 y1 R! Y
8 o% L- }5 H+ ~5 t! U+ I! {+ {
" Z* \* C, {/ W' e0 U, v& [$ ^8 p& Ffunction RemoteControl_SimulationFinished()
# a- H" M8 w' w6 \{ ; I! q+ W6 j+ `! t
WScript.Echo("Simulation Finished!"); |