Example of a JScript
7 n2 {5 L% E1 H% uvar vbOKCancel = 1;
1 ~0 T+ U1 ~. S; w4 svar vbCancel = 2; : `5 F# _# A+ ]2 s
var vbInformation = 64; ; b* q8 Q3 r! |
var Finished=false; 0 l. ~! P$ S9 j3 w; V7 {* T
7 ^1 d( M% W5 ~; F' g8 m: |
var WSHShell = new ActiveXObject("WScript.Shell");
2 a& m+ I* R( g0 J9 m7 C
! k$ I& @' x, w5 {. L, j( G. F& Tvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ( F& Q! D# k$ ?: j' o) c
8 B8 x# e9 \8 J! ~0 F p% Y
simple.SetLicenseType("Runtime"); 9 J( `- e* R( Q' `8 ~0 H
% S3 J9 J, e$ z, M1 S: C9 otry
' ?& N+ V; I" |: W# t{ . h& |1 X, {1 p
// Enter the path to a model file!
% D0 f; e1 L% T! l4 _: ]: z simple.LoadModel("C:\\Models\\Test.spp");
4 Z$ j! B% C+ a0 ~4 ]5 G% S4 z& V8 D+ {}
# v: g+ Z: o" ucatch (e) 1 y- J U& t& G2 r4 Y" d9 ]- ]% R
{
1 k6 _# r- h# h! L1 X$ x/ q7 W8 T WScript.Echo("Could not load Model!"); " W' Z' S$ v( y. e' E) o1 i3 b
WScript.Quit();
' Z- y$ p; }) L% x} % M# E2 t, W5 E& y% _ Q
0 b7 p. A+ k% @" m( E' u
try
- ^$ h" S) _& y3 H' z+ H{ $ k" }# g3 M+ i0 w( B8 K6 h9 B" p0 w+ A
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
0 T* s; \7 q/ \* z* x5 v4 d r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); % ]% Y+ {/ |% Q2 K5 J# Y% ]
if (r == vbCancel)
3 q3 y$ b, f; l9 ]1 j {
/ o- ] t8 }" ~ I simple.CloseModel();
) V: C7 a1 j* e1 y* P- o7 t n WScript.Quit();
! e* m# {* S! C9 T) u4 L1 C } 4 s# J# D7 `' @8 h8 ?. G% y
} $ d9 a$ P2 a# n) P; y
- n% \0 i H* s: I( T3 ^' P
simple.StartSimulation(".Models.Frame.EventController"); + x4 I) m. P, W8 f
0 A* s" [; s1 T6 D# i3 \$ v- P
if (simple.IsSimulationRunning())
% v) V4 L d+ S- o2 ] S; g& Y WScript.Echo("Simulation is running!");
: D5 r6 c! _) J
, F5 B5 T2 R" f M- x// Wait until simulation is finished
/ C$ l. R9 q- u$ U+ r2 _& qwhile (!Finished) WScript.Sleep(2000); ' e! D* q( ?' {& h, b9 }3 H
# ?$ D5 Z5 }6 ]5 z! V6 J
simple.CloseModel();
: H- _2 j0 A' F8 A, esimple.Quit(); ' L: l$ y& S& W. Z8 N
WScript.Quit();
. E# Y. A, N% c& a v 9 U3 L7 s. C- j* M, t
- H$ s. m1 F& s0 N$ c5 _
function RemoteControl_SimulationFinished()
4 J S9 y& P, n8 c: d{ 6 r }0 A/ G& |5 X. ]( [
WScript.Echo("Simulation Finished!"); |