Example of a JScript 7 {# _5 p3 p$ C" E
var vbOKCancel = 1; 2 r- O, l! X: O; @9 Y
var vbCancel = 2;
9 b x9 g5 [8 dvar vbInformation = 64;
$ V* S$ i+ P) j; Y; Qvar Finished=false; 5 g6 V! x: @. P9 [
$ N9 ]" W* w' @4 w
var WSHShell = new ActiveXObject("WScript.Shell");
% y3 S8 p. g" v3 u
/ {9 Q" k; C p8 Q. `var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
7 X& u0 e7 G8 F/ f , {) g- ]$ L& C) }, y+ d
simple.SetLicenseType("Runtime");
. ?# i2 ^- a' `& K( t
. E: |/ U5 R+ U# F3 n. `9 Z P5 ~9 o( stry
; W5 F2 _" ]7 t! {9 B" l{
% Z3 o9 N$ s- ]) ] // Enter the path to a model file! : ?, Y) V+ b% K/ M6 z4 Z
simple.LoadModel("C:\\Models\\Test.spp");
' d8 h/ V% d0 p, ~- s}
* Z4 I# G/ _# |catch (e) - d7 {0 |# V' ^# Q6 @
{ 0 R7 j* t) ?" X$ |9 ?
WScript.Echo("Could not load Model!"); & G3 X& Y. P8 J0 l. r* Y0 j" y9 L
WScript.Quit(); 6 Z- N _( }2 |! U
} 1 f8 d) E! e& `) l
3 n+ F7 ?: L+ u/ c
try 4 Y" u* ~2 ?* b! O
{
/ y1 F$ R$ V1 H" ], O# H7 B" t" |3 U9 ` simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 2 L9 {$ X4 g; \' ?5 B+ g
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 9 k0 w( \1 S' K4 h
if (r == vbCancel)
+ F7 u, G; V( h9 P$ E, T, ~ {
' n; \3 n( A7 M2 U; B2 B1 [5 M+ u simple.CloseModel(); / R# r! [6 A; ]3 R0 F
WScript.Quit();
7 K$ e9 S5 |; u( x }
# v( O5 c3 c1 ?4 o}
3 B3 m% @. Y' U. Z7 |" ]# z5 G3 y 9 R- Y6 }% K1 z. P
simple.StartSimulation(".Models.Frame.EventController"); # O( L! ?8 _2 r' C& ]
+ |( ^. c ?* P/ T, a( Y! X
if (simple.IsSimulationRunning()) 5 ~3 Y" r$ ^& V+ M1 T2 Z1 A. [
WScript.Echo("Simulation is running!"); 9 S7 W! s! |" {2 J$ `
. M: p6 ]1 l W' N I0 C
// Wait until simulation is finished
I4 `# ^& T( Q3 {0 A Y/ x! z% jwhile (!Finished) WScript.Sleep(2000); 1 N* t" K# X0 F$ L
1 [" A8 G6 P. u' S: vsimple.CloseModel();
* I, G! Z7 @* D, Lsimple.Quit();
; J. Q5 u2 l0 Q$ ~WScript.Quit();
6 j( P Z4 [7 Z8 d K- z
0 n Q0 J: ]. o2 `" \( o# ]0 K
/ N# @$ W, ?! W3 U$ j* R/ zfunction RemoteControl_SimulationFinished()
- R3 ?$ A6 y" g0 m) A{ N6 C3 J. y ]1 c+ B t0 O
WScript.Echo("Simulation Finished!"); |