Example of a JScript ! ?/ K& n- Q* e- t
var vbOKCancel = 1;
& M" {" p4 `* o: E% {/ gvar vbCancel = 2;
/ t4 A' r# Q1 X3 x$ k, T- dvar vbInformation = 64; * a4 W4 J, d0 S$ `" ~
var Finished=false; 4 y, [& l4 q) t. t
# B. f x0 I. ]var WSHShell = new ActiveXObject("WScript.Shell");
* O* }& x& u. K# T" k4 z: X% b - t( q8 y* {+ S4 z$ x
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
' N6 B3 @) s! ?& U% T& k 6 C4 ]4 {; Q4 A$ Z z- X, {
simple.SetLicenseType("Runtime");
. T; W) _* T7 Q0 S/ C
' w5 w6 e8 {6 \6 dtry 2 W# }4 G+ _$ G( J1 Z* U$ H6 R
{ % c/ G5 J% h! K$ P& E
// Enter the path to a model file!
& f7 d9 [+ K( h& X* h1 ? simple.LoadModel("C:\\Models\\Test.spp"); - D% z6 D7 {! C+ P
}
) s5 ^7 T, H: G1 k7 m* ccatch (e)
/ n+ E1 E* }, W5 u4 v* `{ 0 ?- D9 I; a r. N9 k+ s
WScript.Echo("Could not load Model!"); ; ^! D$ @8 Y: R
WScript.Quit(); " o' O3 d; n$ p
}
% r$ s9 {, `" o+ D) ~7 E2 l+ ^
- L6 M# x( J- p* F* wtry
. p e6 y9 W% ?1 _5 E( s{ " z; c1 r- ~0 d2 M
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
( P: @0 l# j7 J4 s5 B r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ; O H$ ~4 E4 V. b* S! U9 [/ i0 t1 {
if (r == vbCancel) * A9 _8 Y1 h9 H* ~$ A
{
0 C8 ?0 X; B: N6 C( j8 S! ` simple.CloseModel(); 0 {8 p. R- ~" J( B8 |, y
WScript.Quit(); ! K, j( Y# k) ]6 u: m
}
: [+ ~9 R4 k! ?} 3 |# O" g7 g* g" z% g9 L4 G0 m/ E
' Z$ w: N, y- c# ]simple.StartSimulation(".Models.Frame.EventController"); " G U6 u. U7 { d( t9 c+ n4 e9 k
8 y2 |8 P/ {; P
if (simple.IsSimulationRunning())
1 Z( [$ @$ W! h: r+ F1 l: ^ WScript.Echo("Simulation is running!"); 4 n. e1 H# S8 t( k9 R1 v1 S
! L5 E6 A$ ]; q: l6 Q. r6 C// Wait until simulation is finished
. |; d& U/ {; `+ Z$ owhile (!Finished) WScript.Sleep(2000);
* m0 L! z8 X0 W t1 w$ D: q " R+ @% s# Q, T
simple.CloseModel();
: {3 a0 u4 {* O* Q: [simple.Quit(); & [0 F4 W, _2 N: [0 w
WScript.Quit();
) B8 {: X) _" D; v9 B( ~* G& e! Z 8 b% m7 M3 g; j% z, a) B5 w0 N
! Y8 ]9 w; p# U6 B' S
function RemoteControl_SimulationFinished() * t) y, H4 h9 @; M$ r( T
{
$ ]# _/ _( A( c; s/ t; m WScript.Echo("Simulation Finished!"); |