Example of a JScript 2 G# O; x, a) A( q
var vbOKCancel = 1; a( M. [; ~6 z1 j; l' h
var vbCancel = 2; 1 L7 k; i1 ^' L. n1 Y* I
var vbInformation = 64; - v9 }$ I/ N1 S" Z; X
var Finished=false; 1 H7 n" h2 ]& e& U, g8 j
7 b7 t( i4 q$ R
var WSHShell = new ActiveXObject("WScript.Shell");
P) Q. O/ p( {- Q5 n1 ~ 0 Z( |1 Z7 |! {& [
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
; X4 q3 ^2 A M ' ~% M' H% h) T" ?) F
simple.SetLicenseType("Runtime"); 9 c. b3 [- q: Y( r
: {: ~) A+ n: g7 q7 b& s! @6 ?, d$ s
try / S$ z: G# u9 v6 F7 {3 S ?+ H
{ . a& N2 P( A2 l9 F
// Enter the path to a model file! 7 O: n1 U( u" C1 ^
simple.LoadModel("C:\\Models\\Test.spp"); ( [# s6 w# }0 ]) g& ^+ s' c. e
} . [+ `7 j2 i2 [( q
catch (e) $ Y h" y, j1 b5 \+ a1 y# r( B
{ : ?- M9 ~3 ^# J$ p
WScript.Echo("Could not load Model!");
' A1 g% ~- w ?- |. ^ WScript.Quit(); ' a/ c! e' `) a2 e
}
* O2 h* ?! H) N, _+ _1 t
- r) Q$ b6 G* `try
|8 L0 ~4 Z) d$ s- \+ _" ~{
7 |, o. J6 k- p1 L( n I% Q simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { H! t7 s# h& q9 q
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); : y/ ?' ?; s4 I9 O. ^
if (r == vbCancel)
% @ N/ H4 @2 J3 ` { d/ X& a: Q* G( \# @
simple.CloseModel(); . v3 Y" U0 | N" P& J0 Q1 P" c& @
WScript.Quit(); . s i9 I: G' ] [: k( w4 k
} . G& O: E; u3 O' Q
}
$ P" ?/ w0 I2 S+ T - C0 U- Q- u0 I- e) `4 g
simple.StartSimulation(".Models.Frame.EventController");
; l4 B9 R+ ` g$ J" P8 f" Z# F' h
F! [8 t% \, k* v: jif (simple.IsSimulationRunning())
) h( r9 R7 E/ _9 N- _ WScript.Echo("Simulation is running!");
. H% ~+ d( I) c$ p - C! W1 F' N( |. V. K
// Wait until simulation is finished
! m N" N* J" xwhile (!Finished) WScript.Sleep(2000);
4 d* v! E0 J, V' w( `' c/ h
- _ `: J1 i1 T+ A7 u b9 jsimple.CloseModel();
9 l/ {# j7 C4 _; c& o% B8 ?simple.Quit(); 7 A, }8 r; E5 y
WScript.Quit();
& v5 ?4 [6 m( j" w ; H+ e# X4 Q. o' S+ G$ {! N( s* L
3 E6 a& k2 U2 Ifunction RemoteControl_SimulationFinished()
% L& P+ M& B+ `, x1 l# A{
9 E# s8 f' v7 h) p' p6 c WScript.Echo("Simulation Finished!"); |