Example of a JScript
, ~7 x2 o) }$ f( P: O) yvar vbOKCancel = 1;
* P% `, q/ ]+ t. [var vbCancel = 2;
* U D: ^, J2 W% V+ cvar vbInformation = 64;
% ]- y# u3 Q' B( bvar Finished=false;
; y: Q: k1 r7 g, e/ q* P 6 z5 z. H! C! R- I, D3 i
var WSHShell = new ActiveXObject("WScript.Shell"); ; a# s( O0 T9 H
2 _% @6 ^% P' t# P8 S& W* h
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); " K5 T K0 A3 j# E# {6 I! X
& ]. n! x; J- \4 e! X
simple.SetLicenseType("Runtime"); * Y$ i6 I7 T6 J/ D2 p1 d
4 E' @$ L! }& I+ |0 E9 k
try 2 P- c" t5 v1 u2 e
{
+ ]8 M% C6 B, G1 |' o! c7 W // Enter the path to a model file! - W; o1 d8 e+ v
simple.LoadModel("C:\\Models\\Test.spp"); 9 B& {. t/ u% _6 X* F
} 3 T' x B+ n5 ^. d1 g
catch (e) 8 I; D3 s- u8 M3 _5 [( E3 h0 a
{
4 Z9 _) P, x9 U" A: g. K3 Y3 ^ WScript.Echo("Could not load Model!"); % e. U- R5 Q' p1 W# c; K& t
WScript.Quit();
" Y" b# D& Z/ V n} 6 Q H6 a" ~; Q& }# g
8 o" v3 N* }$ w+ `try 1 ]3 A2 ]# k) N$ w% |. d
{
4 D# O5 X: E1 \9 Q/ V$ s8 B0 |% W3 K9 ^ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 7 L) W" K4 d5 {+ J* d/ K# B1 @
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
1 ]) F4 q$ W @& Q/ W7 f. Y if (r == vbCancel) % S4 H* h; b8 q. Z6 Q
{ f. W( E' F5 I
simple.CloseModel(); ' E S) s; p, s1 _/ |$ X
WScript.Quit(); $ L% M7 d1 n( F ?. w5 `/ g
} * s$ ~$ |8 D4 v2 K; R
}
/ e t0 ~9 O1 H" _7 \! I
+ l0 K& K3 P- a. V/ V" Bsimple.StartSimulation(".Models.Frame.EventController");
2 p! T+ m& j6 E' G+ Y % b# L' N8 t# k' V E/ V5 B
if (simple.IsSimulationRunning())
. a1 y8 W$ Z. E; ?* o9 N* b4 f! W* G WScript.Echo("Simulation is running!");
# }8 `! A. k, N! y+ @
% U/ L. k& _ z0 u# j7 \4 f! _0 Z// Wait until simulation is finished
" p g' W$ W& _4 l" C" kwhile (!Finished) WScript.Sleep(2000);
# H% F! J6 Z. h: |2 |
0 d5 E% E0 A5 v- \: a& |: N' _8 |simple.CloseModel(); $ C- W5 Q+ j! S
simple.Quit();
) `$ `8 n( V* A3 N5 G- G$ k8 P+ JWScript.Quit(); 4 V* B1 P( T5 |( s) `* R" A x
5 ~) k. d; l2 y9 j7 j/ `/ U . X6 b) A' C' n) z8 v' }9 D3 P
function RemoteControl_SimulationFinished()
2 r3 e! }! }& J% W8 V. T/ c{
6 n; q* r7 T8 O9 ~4 `/ o! m% `# _6 t WScript.Echo("Simulation Finished!"); |