Example of a JScript
7 K3 n# p/ v* bvar vbOKCancel = 1; % j0 j8 d2 n5 _
var vbCancel = 2; 3 Y& n& Y0 X1 ^ S J# Q
var vbInformation = 64;
; x6 s4 V9 e) i, _& \' Evar Finished=false;
; u" J T/ _ j4 N1 U . s3 C# I" a v( X4 _' t5 y
var WSHShell = new ActiveXObject("WScript.Shell"); . s$ d( L: x1 _& e/ t+ V6 W+ p# J
- ^( c: D0 I5 N! uvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ; A9 {) Q; _& p' l! g0 ?
/ f$ A [; P/ F+ M! d
simple.SetLicenseType("Runtime"); 8 N+ U2 W% L6 r1 M; c7 F; X
1 Z6 X7 n; p9 z+ B9 r! y+ |; \3 I1 X
try ) z2 H5 ^$ s- P u$ u* Y7 {
{ / ^7 M+ T8 b3 n$ {0 y& A
// Enter the path to a model file! - v" e+ F" V' {3 z
simple.LoadModel("C:\\Models\\Test.spp"); ( g/ Z( B* D( ` B# y9 z0 B
}
7 X5 L% J( j8 I1 l( Mcatch (e)
- x4 f) w, T$ N- s; ^{
7 S4 v+ e3 r" Z5 @/ U WScript.Echo("Could not load Model!");
5 {2 I9 o; H/ T: O2 F WScript.Quit();
' U; X) g7 z3 |6 [( ~4 v. w# c} - G+ z* z1 b2 u' n; x
9 I4 D2 u, M9 b# K
try # Q* D7 y1 T- [! | d2 i
{ " V8 U8 P7 Z2 t, }$ l$ n
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 2 I( Z3 T% C% `0 m, C1 q: n! a- f$ {
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
' M) ?+ a1 `: \% V+ Z' _! T6 y$ t if (r == vbCancel)
* f, U! ]( X( `# L7 ]+ F, ~ {
3 v- c& R0 M1 h simple.CloseModel(); 0 u6 }2 p1 _3 T" O6 u* d
WScript.Quit(); 3 l% P5 `/ e2 J7 W
} 9 h m4 [/ m# t! M8 w
} ! @+ y- ^7 h- K
) ^+ ~$ v' S1 m: g" h+ L( fsimple.StartSimulation(".Models.Frame.EventController");
" @2 x' G6 ]! U. z! l( V+ t, B
+ C; P+ x5 i3 @if (simple.IsSimulationRunning()) & c' h' \& Y' r( R* l3 ^) F
WScript.Echo("Simulation is running!"); $ d; k. J- r6 \
! Z$ b* F! Q" z" a// Wait until simulation is finished % U7 ]7 [8 ]$ K1 Z
while (!Finished) WScript.Sleep(2000); 3 ~" s* l% x9 Z+ g+ i2 F) { Z
* u' u9 ~# Z, m' `
simple.CloseModel();
1 r5 a6 Z( A6 ]5 ~9 x" {$ K" ], }simple.Quit();
% m& _3 X1 p7 t" uWScript.Quit();
* V8 ^- `! a& V; n( j0 `# x
* B+ W( L3 F7 M+ `4 V; M
7 E* g5 ~; R, F r3 B }! efunction RemoteControl_SimulationFinished() - T" x, i. Z7 [: _# ^
{ 9 ^) g t/ A$ k
WScript.Echo("Simulation Finished!"); |