Example of a JScript
% y( z6 T/ }8 z. c1 b9 ]/ Ovar vbOKCancel = 1;
0 e% r3 J. ^! c" Nvar vbCancel = 2;
2 j* x3 b, L. X& ^- ivar vbInformation = 64; 7 F0 B; H& x2 w X7 H4 f
var Finished=false; ) y, F5 A. }# W. Y' X$ e9 J) L6 k
& w8 Z9 H8 a4 V
var WSHShell = new ActiveXObject("WScript.Shell");
! \* f) Y5 C# [9 U& O . V Y6 P4 z C
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 4 P' F9 |$ d5 ?2 h* @" ]3 R
$ S1 m$ U4 r) L- @. T' O" g
simple.SetLicenseType("Runtime"); / E7 v7 I# q5 O' H+ M1 ~8 I
0 R0 `7 t$ x$ c( htry , |0 v8 h l0 P0 k$ Q
{
9 w. ^3 G( V( ` // Enter the path to a model file!
' J0 `* I) j' p1 t/ X& O3 x simple.LoadModel("C:\\Models\\Test.spp");
) J6 @0 a) L9 M9 x4 B; S' A} / L, d5 u5 p7 p' g! S* ^% A& b' S
catch (e) 9 q6 u2 j' {" _+ L2 U: K/ B
{ 7 P4 V0 j9 I8 |
WScript.Echo("Could not load Model!");
" f& Z) Q2 Q0 c7 L1 G' y7 Y WScript.Quit();
+ B5 T1 H# T' F5 ]; G}
# ?: h9 J2 r$ l2 Z
# s( ~2 C& u1 _7 j* Otry
8 H2 c/ `2 y. j$ Y: v: m{
5 d2 N' i: {: a" _0 Q S simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 6 c& W' H4 D# u+ \
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 5 r& Z8 t5 q: f
if (r == vbCancel) : |! @ h7 x( `% b
{ 3 T6 T4 d; b" p/ L! x) Q3 @# o
simple.CloseModel();
) h) u3 p9 j9 {7 b+ f! x' w: o WScript.Quit(); 0 g% |4 H( N: s0 Y% n7 `) U
}
# B% Y* e7 b$ A% H$ ~' f/ ?} + `4 Y k! P! O0 L# s8 k/ {1 a1 t
, F. W& g5 L$ H. M4 W* H& L" i6 g
simple.StartSimulation(".Models.Frame.EventController");
9 d/ q3 |2 t1 D0 G+ f3 _: e
8 y7 f+ s! w1 ]7 t( \9 W! Kif (simple.IsSimulationRunning())
+ r6 }& w& \1 m+ B4 f$ I) n8 ^: W, U WScript.Echo("Simulation is running!"); " z, {2 x) I- p
) Z$ g4 D3 e( f; C* S5 O# ?
// Wait until simulation is finished
. _% w# P! j. n. X; B* twhile (!Finished) WScript.Sleep(2000);
/ _2 Y5 C2 B) N% u* t 8 H& [5 `$ u& M: D( n; Q& g
simple.CloseModel();
: q; P% {" {3 s, p) O: ssimple.Quit();
3 B3 p* a1 ]9 U; l1 ]WScript.Quit();
9 w7 f- O6 n9 Q; t: B9 W3 I' E 9 c# [+ F9 r' D/ D* m2 Y+ r
6 ~' @# h: j! z7 d; [9 Zfunction RemoteControl_SimulationFinished() $ v0 i+ H, r0 H$ ^8 C' q1 L+ v
{ ' r% Z7 n- [/ z
WScript.Echo("Simulation Finished!"); |