Example of a JScript 4 ~4 L# E' g3 i4 L% g \
var vbOKCancel = 1;
# x- [' Q9 ]( S4 T i* M+ w4 ovar vbCancel = 2;
8 T' X* q" ?+ Y$ u3 }! dvar vbInformation = 64; / H5 Q( p) j1 x) F B
var Finished=false; 2 b3 d x2 [" v3 G F
; g; Z) t N; f3 F' Z6 B
var WSHShell = new ActiveXObject("WScript.Shell"); 8 S/ M9 r8 L( ]* D& m
& P5 l4 b0 ?& e6 Lvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
) q' ]! Z" m# \( \% U5 { - C8 X1 f* f# h1 G7 f& k
simple.SetLicenseType("Runtime"); 2 g v) }* _+ x2 F" {
) G: z5 D8 z c7 N; _" ftry
& ~( h! x' T' @: |4 E# k{
. E+ ?: Z+ R# s# x* Z1 n, H // Enter the path to a model file! 7 }2 i3 Y6 z$ V) G9 C' t
simple.LoadModel("C:\\Models\\Test.spp"); 8 Y, x9 f9 w# q/ H( i
}
4 ^, P5 i. r' I J$ Pcatch (e)
3 f! P; J; c4 L4 I# ]" Q{
# q5 U9 E* M' A. _) W WScript.Echo("Could not load Model!");
* |, V s% Q" {7 K0 C* i4 ^0 J WScript.Quit();
: R( Z- m" l2 C; R1 m}
+ R7 M, E9 D% j3 W5 ^2 F 8 }: E+ H3 n+ X. f- @
try 9 C9 U7 Q) u/ A; @3 F
{ ) _2 V) E; R# J8 @* @9 A
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ! X# M# T2 |8 ^0 d- Z
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
2 R5 I% a$ V3 v( s if (r == vbCancel) ; X9 y! X# V4 x$ V$ U
{
! L0 j$ u0 n* V1 { simple.CloseModel(); 5 s# B/ N3 H! @( ?5 ~ a% T: [5 d- c
WScript.Quit();
, F* t( z i9 J# C$ P, Z/ h+ s }
* P* @' D+ R& Y( ~4 T/ \0 J} ) s4 ^9 ^+ Y+ `
+ d) K# D7 c* E% R5 isimple.StartSimulation(".Models.Frame.EventController"); , `% h& ~5 ^! l) u; m
m2 [2 E o- yif (simple.IsSimulationRunning()) + m) n7 p$ n0 \/ P4 p& M
WScript.Echo("Simulation is running!"); + @/ p) S8 X6 O9 S5 g
1 _ c- `2 Z% \6 T \$ B/ B; l
// Wait until simulation is finished
) \6 y6 j7 Z7 bwhile (!Finished) WScript.Sleep(2000); ; }4 k6 E$ S0 _; ]9 H$ _
* W6 K- d# t8 zsimple.CloseModel();
3 e; }' h0 i5 n& Q/ f! E% Y! U8 ?simple.Quit();
s7 x4 J, e$ \4 uWScript.Quit(); $ G; J) t% m: [$ {$ D F' z
7 H! W# z, R6 K
. t3 p4 E: X2 g' [5 t! r0 A* qfunction RemoteControl_SimulationFinished()
2 q3 o1 {5 \$ {8 O) `* O4 H9 X{
! U# a0 _8 P* U6 Z6 ?3 T# g WScript.Echo("Simulation Finished!"); |