Example of a JScript 1 }: i6 S" k4 _- V/ V/ H5 q' v
var vbOKCancel = 1; ' P8 o3 O& } l% r
var vbCancel = 2;
3 k o/ L: b6 T& Mvar vbInformation = 64;
6 `4 ^% q! J. R" Hvar Finished=false; ) X4 p, {& l; ~* S
. B" |/ G# u7 ?# S
var WSHShell = new ActiveXObject("WScript.Shell"); 6 ^- F( Y7 e* M! d7 _
8 x/ N5 X9 ~3 q m% ^+ _var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
0 r+ j+ _ X- i" Y! u' ~ s
8 C" e! F( J5 Bsimple.SetLicenseType("Runtime");
T0 {# G( J( p9 `3 J
$ z; n9 ^7 z4 c ~8 ^7 U. Utry 9 ?9 i( ~# ^5 A+ Q# Y
{
! u ?" T3 `4 T# }" o // Enter the path to a model file!
% I: K" i) O( F+ Y/ A+ o5 u) C simple.LoadModel("C:\\Models\\Test.spp");
( S P' `% f6 K7 k}
R. c# M0 Y+ D9 ccatch (e)
: F# c: J+ A& q$ l+ N7 |1 V{ - Q, K% U P. v6 l- K' d
WScript.Echo("Could not load Model!");
! I+ t0 P) c, m7 e WScript.Quit(); ' Z$ t3 T: R6 r5 r( d8 F4 _% @, d
}
& I4 O5 q1 a4 y3 C: m5 A& K/ v & @5 d: U! k5 U) B( G' g
try
3 N& u& c% e7 D2 Q{
/ w; D: {) E2 z simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 7 K4 d$ h' f* ^4 F
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
/ J" h) |% e" h+ E+ T) U if (r == vbCancel) / q+ J, |5 w: L1 l ^
{
* p R; g( ?; `% g$ j6 k simple.CloseModel(); $ d! s+ o: E& q6 ?4 L% w
WScript.Quit();
/ ~$ j+ `- y9 j } ' D0 v8 t7 |0 |
} 7 S" {) }) e7 ]8 {8 c0 d
% ~9 g3 o( b2 C
simple.StartSimulation(".Models.Frame.EventController");
. L# S# P& V. P- r* o2 S$ ^" D
) [7 F5 u$ r" |3 s2 s6 W1 U+ Aif (simple.IsSimulationRunning()) ) i% A2 g( n6 p$ f" K
WScript.Echo("Simulation is running!"); & @# i: n( l* d8 t
. @+ z# D. E5 o0 I) K5 ~// Wait until simulation is finished 3 j) \) I% X ^% A2 K* M
while (!Finished) WScript.Sleep(2000); ( s) f1 S0 F- K: P! i& H5 n' ?$ b
. U$ n3 W' U7 a
simple.CloseModel(); # O) z6 l, n: W: T3 ?3 h" w4 A
simple.Quit(); e5 a" F) V" [9 d, ^( w1 c: ^
WScript.Quit(); 8 D1 O: ~2 ?2 B0 m4 R
- W( j& _ X/ @
! J8 N$ U9 @- a2 f5 b& {: ?function RemoteControl_SimulationFinished()
& c2 d: C9 T9 O6 ~{
4 N" h- N) [2 j8 c WScript.Echo("Simulation Finished!"); |