Example of a JScript 3 h- ]* o% e) x# m7 }# g
var vbOKCancel = 1;
8 |" @5 q0 Z2 w% ivar vbCancel = 2;
4 m( F4 @$ u" J2 }+ ~' @" D0 q1 tvar vbInformation = 64;
/ b6 U/ Y$ q D$ z7 }var Finished=false; + F- H3 y* Z9 w, C
3 X7 a' w; J0 m- Y- j) @var WSHShell = new ActiveXObject("WScript.Shell"); 9 O$ u" `' D3 R6 }1 x2 u5 y8 O
" W2 Y% `, D( A/ S# L# Z" {: D
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
8 y) t, R( `3 P+ c) ~! W( w1 q
7 }' c& ~, F) V+ \ \& @- {+ Ksimple.SetLicenseType("Runtime"); * s$ b6 U: `* ?
# ]: C& C: F8 X6 h
try
4 O; A6 V4 S6 Y* P{ 9 M& O7 q) m2 [' W, A' n3 u% K! m
// Enter the path to a model file! $ l2 I, i3 f' T) L- [
simple.LoadModel("C:\\Models\\Test.spp"); + \& ?) e+ @" e$ P# M5 X) ~3 O
} 8 j( C# b, @5 `
catch (e)
1 b: A! t* {1 y, C# B( W{ ! b8 D& y0 \, z4 f P
WScript.Echo("Could not load Model!");
3 V& [7 F3 e9 i/ J8 D WScript.Quit();
1 j# s5 f' t# j- D} * W1 [) b4 H8 r% ~
2 X$ X4 b0 N9 O1 a4 Ktry * R K0 r0 |; R/ W7 x. X5 O
{ ) `. M0 L# t) T; s2 {
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { # a9 x( N0 G4 P9 C; R
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ( u* U- g! J- O! M) a T
if (r == vbCancel) / \' ]2 u5 Z# N
{
: W/ Z6 z1 u4 Q simple.CloseModel(); / f4 i% X4 {3 l* {$ V% Z
WScript.Quit();
) D; R! q1 h1 t$ a. i) X: a } " Q! B/ P4 Q5 h/ F7 p' }" g2 o
} * }/ {6 Z4 {& M$ H. ?
2 v7 L# a; x2 z* _2 \3 ksimple.StartSimulation(".Models.Frame.EventController"); * _$ x% x( {3 c9 x: G9 Y; Y& y' G
5 a/ F. e3 n% Z6 ^
if (simple.IsSimulationRunning()) # G$ O" ]! G$ M* U3 Q% K
WScript.Echo("Simulation is running!"); 4 Y; p6 m/ J* A& \+ [$ x. T
i. P4 D* l8 q% n1 Q C
// Wait until simulation is finished
l! c7 x; [0 M! vwhile (!Finished) WScript.Sleep(2000);
' i% U5 u, V3 i D; W# t - w7 V7 V2 G8 }3 Q/ K6 P3 c/ ]6 b
simple.CloseModel(); - y% r/ K: J, V
simple.Quit();
; P# ` k* L: d XWScript.Quit();
+ y; Y$ A V. x( t: p4 V
& O1 H# ^9 R1 F @8 U$ E
( w I( G6 ?1 c5 P# D' l$ ?function RemoteControl_SimulationFinished() 7 N6 o0 R& a1 [1 k( H' c0 O [
{
( |/ \' E- Q) a! P# G# ^ WScript.Echo("Simulation Finished!"); |