Example of a JScript " R( ?* K9 \' Y' F
var vbOKCancel = 1;
& Q- M4 A' H d. t8 gvar vbCancel = 2; 7 j/ N ^4 {# s8 J3 z
var vbInformation = 64; / i% @; m3 B$ M- i; z: d
var Finished=false; 9 D I! p5 I+ g
& x( S/ ^! y5 w, J1 [. Q6 z: j
var WSHShell = new ActiveXObject("WScript.Shell");
& \: j5 |( e; k$ b1 I2 ^ Y5 N; Q' L- x/ O+ y
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
- \! ^% y4 c$ |/ l/ U5 ?& v
7 j, n) Y& S. ^8 h9 z1 ~$ R) }% ssimple.SetLicenseType("Runtime");
_# P& |# H3 i3 G + y7 y4 Z. s& X
try
5 Q! Z) y( h9 N' h! A0 S9 b{
; }1 g* c$ e* y // Enter the path to a model file! 2 L) y7 X: b0 m6 S% \3 T( a8 r! q
simple.LoadModel("C:\\Models\\Test.spp"); 8 O/ k- `$ N1 p3 }5 q) q$ p( Q9 @
} T2 n) y8 L; C& O& l
catch (e)
+ C1 O7 a( @. J# B% F& o{ 4 I" H3 u4 o# s; _
WScript.Echo("Could not load Model!"); 3 u# g; R; z& l! M6 S6 _( ]" w3 s
WScript.Quit();
0 @& ^6 N9 t2 M) c) o8 p% _( g* h} n. r: x6 F: V" B3 M. z
' P8 y9 Q# @; e% x6 ^" o3 e8 Otry % @. S. ^0 X d
{
2 |/ e2 ~" K; {, e+ F" @7 O simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
6 ^# ~7 W; _& Y0 Y% s! j3 N r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
% J+ |8 n1 @/ I0 Q2 X if (r == vbCancel)
& e# W( w9 c" W { 8 s! G6 C. Q4 S9 {' t+ U9 o$ B5 |
simple.CloseModel(); 2 n" T/ Y* O# v
WScript.Quit();
( E! L: v% z" N! z! D }
8 E( H7 F' {, S" K2 a3 v3 w W}
6 r; x% k. u r5 S& L' d
5 [2 J" n) D# E, T8 z1 s5 V- {1 Msimple.StartSimulation(".Models.Frame.EventController"); / k& _2 s8 C# M9 s5 a* x
9 w+ w9 p' h2 D" H3 d* p& D( F% Pif (simple.IsSimulationRunning()) : w/ Y! S: @2 u8 P% c9 Z$ X
WScript.Echo("Simulation is running!"); : l) E& `5 @# W. H/ c
5 q! ?! }+ `+ V, P// Wait until simulation is finished
# M m X' f; ]9 ~) uwhile (!Finished) WScript.Sleep(2000); ) R0 Y* l$ {! a2 U8 }! e" F
; V! Z0 j% [; P$ L4 l
simple.CloseModel();
- u2 [2 T9 y6 X9 q# d+ Jsimple.Quit();
+ `. |+ N2 j0 d5 t9 Z' X# v9 PWScript.Quit(); ' `9 Q' L# Q( W1 ?$ U; z
$ Z/ l: X! c3 `: m1 U/ p' ~
8 V4 m5 {$ i B7 x) }/ ofunction RemoteControl_SimulationFinished()
T/ B" S# P* f2 m, }4 F{
) t) R- s i4 G4 { \: x' J WScript.Echo("Simulation Finished!"); |