Example of a JScript # y( \( g% n4 F& X0 b) t
var vbOKCancel = 1;
# x) m$ a" i- _) I6 r+ ~4 ivar vbCancel = 2;
; v* Y" Y8 V. e4 F0 `7 \3 Uvar vbInformation = 64; " p- v `* y+ m8 J$ R* {8 `
var Finished=false; 6 u$ C; i6 Q. ]
1 b& ?& S/ r! D
var WSHShell = new ActiveXObject("WScript.Shell");
/ b; v. b ~* _/ b* C5 ^ : s+ s* e# j. v$ i- W4 b
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); , o5 l S7 t, g
4 Q$ @ ~! G0 ?
simple.SetLicenseType("Runtime");
! |3 F7 c& t$ K: ^; z# N5 Q3 P& [
- c& H# i8 v, Jtry ( c- s# t, q8 }( e- M# ?/ p" \
{ 4 | W/ V& D/ {6 a! l
// Enter the path to a model file! & |# k4 ]/ Y8 Y M1 `
simple.LoadModel("C:\\Models\\Test.spp");
! l6 w$ b- M! X$ c# h} " l& D' t) a3 R( Q
catch (e) 6 `; m! [& ]; L8 j9 ?2 h0 c
{
8 B0 w% F& B5 A' H' V1 n7 G WScript.Echo("Could not load Model!"); 5 W* `* v) _4 N+ B/ H5 w
WScript.Quit();
% [# X8 t# r2 I m: {} 8 {& ^3 X: d9 S6 w
" ]" G$ ~( U/ }try 6 q- \$ r# U1 }# t0 v
{
4 A4 b6 s- J# C- `4 |% h* u" q simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
d3 W6 `! X. e* L+ {. |: D r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 7 {# q* K# e9 J7 \4 n& s- H# W
if (r == vbCancel) " {7 g- @9 P S6 Q( z, [
{
2 ?! s1 ?1 y* u4 Q2 k. _3 E& {+ F simple.CloseModel();
1 W! O8 @, }/ [5 D/ g WScript.Quit(); 8 e, b. W1 d0 \( \. t t, D$ ^, h8 h
}
, \6 M( S9 C0 h& J+ S} , E) s) j4 T/ ^ v
7 ]- i4 x' `1 I$ {& U5 o% |( ?
simple.StartSimulation(".Models.Frame.EventController");
2 R9 a, |- m; p: T6 V ?5 F $ n7 h* n& v! x+ z R
if (simple.IsSimulationRunning()) * n/ K* D6 B, B' X
WScript.Echo("Simulation is running!"); ( i% W S& U, l* p) j4 u5 p# E
E; \% w& i" x
// Wait until simulation is finished 3 B8 d% b$ H! Z2 Z' s. S. d) e
while (!Finished) WScript.Sleep(2000); * F" T" F7 L+ S- N
+ a, f6 [) ~+ a/ p: Z* x
simple.CloseModel();
7 N0 j* I/ P7 Y! tsimple.Quit(); ' [8 j. `0 F+ L' y" l" a' x+ q6 O; t
WScript.Quit();
, H: ~' c; n: p4 U
; h) ~$ {! w& ~7 c2 d+ Y * R% Y: N3 V, T# c3 |" p5 _
function RemoteControl_SimulationFinished() / w7 c4 F( `$ h
{
' L- G, Y" \) B0 U8 V WScript.Echo("Simulation Finished!"); |