Example of a JScript
2 S* h4 a3 e& ?var vbOKCancel = 1;
& W4 N6 r L8 s6 ~var vbCancel = 2;
+ e! X0 m$ h4 G; Q3 _; Tvar vbInformation = 64;
; J# D3 p: F& W: i- l/ `8 L; evar Finished=false; % a7 R, {- V9 f# H( ^
: A, P' F7 S6 I' t5 Y$ M
var WSHShell = new ActiveXObject("WScript.Shell");
) Z, }* r* j9 Z
' S( S0 W6 K2 S# jvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 9 K; E1 ~6 R3 M+ L. s% k: _
1 Q6 D4 n6 K& X" ^0 H
simple.SetLicenseType("Runtime"); & b* s1 H# N& D: d1 Z% U+ |
6 L8 m6 k* W' w5 Q% D" Ltry ! v+ h! t/ J* v! J1 S6 t/ P
{ ! S9 d6 P* g$ v6 E' J
// Enter the path to a model file! 6 P. ^1 Q }- @% T9 Y" `' E" h" q% M
simple.LoadModel("C:\\Models\\Test.spp"); 0 [6 q! c O$ E+ w4 K6 R6 m
} ) r0 f& H7 i3 O
catch (e) 5 j, G) r: z" Q5 g8 d
{ * d$ X7 B7 A T0 ?
WScript.Echo("Could not load Model!");
* M0 [0 }" w* Z( M$ G( H WScript.Quit();
7 h3 Q. K; f% U4 K8 R; g9 V$ A; G}
! x8 o1 I( X+ `' F
" } s- U# p; o2 k" l$ ?try , N V. U+ N8 M+ X z3 ^) H
{
% P; }4 a: D- o& m* W2 ^: F) ~2 J simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
9 M8 a* V2 O- B# g7 c) u/ n r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
/ _$ S- E! e( R5 G8 @, u if (r == vbCancel) / n1 ?; k- d& a
{ ) k+ q) J, V. q& o: T0 f& t. Z
simple.CloseModel(); ) p$ u7 P+ X% }' M' \1 |
WScript.Quit();
; N# B9 d6 E0 A }
[# f) c6 ?' [' h9 i+ o2 P" S}
$ g9 z; p% H6 {+ S + J& ~7 D1 B# J1 C6 F6 q/ Q" s
simple.StartSimulation(".Models.Frame.EventController"); 3 K( }9 ~8 v3 b0 ?
J+ t& C3 b: G4 Q2 r5 y% {if (simple.IsSimulationRunning())
( E; P% x, q' W4 o WScript.Echo("Simulation is running!");
3 u' g1 j0 }3 W% [7 t
$ ]+ b! a$ Q( P! }" ]1 u5 P// Wait until simulation is finished 3 v, E) J& Q- {& s$ i# c7 S
while (!Finished) WScript.Sleep(2000); 5 i) S9 Q* R: x" x5 @! F
$ w+ b" B% X6 Z* }0 j7 N! g! d! U
simple.CloseModel(); ( l' y$ T+ p z; S* X) r! I$ V4 D
simple.Quit(); 0 G7 L O6 X. \4 f% B
WScript.Quit();
( w H& r% l W5 C: } b! y! c9 Z* _
: w$ S! D v2 T( C) F e7 ?
, J" \8 n) I/ {3 u8 }7 Z8 Yfunction RemoteControl_SimulationFinished()
3 Z$ ~/ n* g& a1 ^% x- p) l: V{
! q/ }: M! k; {! j) f! a2 _, J WScript.Echo("Simulation Finished!"); |