Example of a JScript
, T( I; m* H5 E/ J7 p5 q# s3 cvar vbOKCancel = 1;
5 ~1 {5 v9 n7 ?7 l" c# M/ evar vbCancel = 2;
. h$ J: R- @' v- C/ ~' y: bvar vbInformation = 64; ' V7 G6 i' p8 Q+ Z9 K# k
var Finished=false; 0 o x/ X' E; { d# U7 i% J! D1 u6 X
/ @8 l! \8 V# |var WSHShell = new ActiveXObject("WScript.Shell");
; @+ y5 C1 }9 L2 ~3 D, H; n
$ k; @+ t. g8 q8 B9 t% U+ v* Gvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
% g" [" n# r8 l; p8 z) g, L: v
" A0 k. J4 b0 ^/ |0 A" ^- R3 Wsimple.SetLicenseType("Runtime"); / s4 F6 E- c2 g5 ^: ^/ z6 \8 I
2 ^: Q# Y3 N+ `try - c2 M! W( b+ n6 x! X' `; U: ?
{ , v4 r0 m8 X6 N/ Q7 z2 j5 [4 _9 j
// Enter the path to a model file! " o8 @* y1 y6 R# d
simple.LoadModel("C:\\Models\\Test.spp");
) F+ g9 q: {$ D7 A9 [+ e9 v+ h} 8 q" F% l3 e* K- K
catch (e)
& B' ~) C: T+ n{
* y' t2 f- ^! D0 N! ^. P WScript.Echo("Could not load Model!");
! T' ?3 ?# v& t6 x1 _ WScript.Quit();
$ o) J+ m# g0 ~0 G} 0 Q8 J- P7 v8 z) R
7 H/ L+ D+ U& h' _try
. h5 _6 S! I1 m4 e: _, `. \{ % h( T I5 {4 g
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
; ]/ ^- [# A# d5 ]( T r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); # b8 h& M' l2 e- y
if (r == vbCancel)
8 H* k. f: T9 q- [2 z" j& k {
0 i& x2 G( F; X$ ?' B: h b simple.CloseModel();
/ \1 A& U7 n. Y WScript.Quit();
8 d* j, y. S9 V }
* H+ M' _% g; X: [$ x6 U}
; U/ d6 B& g7 z: R3 O8 w ' c6 j2 w6 M" h( ]9 H7 F
simple.StartSimulation(".Models.Frame.EventController"); : J# V8 @4 M' |: E
& ?2 k0 v8 X+ t O( e" sif (simple.IsSimulationRunning())
; j$ Y( ]' C& I' T$ {# L# w5 R WScript.Echo("Simulation is running!");
n4 h, L- ?8 V" X+ u
/ R) n f9 B9 M2 I// Wait until simulation is finished
1 o0 }, s2 h3 l8 p% x3 l. [- rwhile (!Finished) WScript.Sleep(2000);
4 ?4 P4 r5 S2 ^$ M3 H% k
% ]$ a- _, x' rsimple.CloseModel();
2 V5 F% J) f; R/ {simple.Quit();
# \5 g" ~6 z; ]9 f" g- pWScript.Quit(); ]0 E$ J: y# s# `) m
3 V5 ?) s" s1 I; J: V + B! a5 j! {) T4 ?& U
function RemoteControl_SimulationFinished() - W' J9 H$ s/ Z
{ % w3 x: C& s+ n! S% t( j* a- M
WScript.Echo("Simulation Finished!"); |