Example of a JScript - u F7 ^9 m7 {. X# X+ r
var vbOKCancel = 1; ' r* X) L! x" k3 U/ J
var vbCancel = 2;
8 M# q/ A2 p3 h# M, ?8 {var vbInformation = 64;
9 N+ o! F' f6 e( m% G' y3 Bvar Finished=false;
& p7 s$ B, h) ^! P
; ?4 U+ T, W3 J7 W: r$ O Dvar WSHShell = new ActiveXObject("WScript.Shell");
! B# f& ]! |; X4 n- Q2 F' g$ z
# ?: C; `2 s3 n& {var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); % j2 j3 o2 x/ w. f3 x$ ]/ T" D" m
$ l8 Y6 k8 Q" F: v+ m
simple.SetLicenseType("Runtime");
" Q: o, P' _$ l& v
b8 L0 ?# H. r- |" I) ]$ ytry # _* F! Q0 W/ h7 d
{
6 u) d9 D+ K8 t7 D2 R. Q // Enter the path to a model file! 0 O/ G8 \. f: G+ W. o( k
simple.LoadModel("C:\\Models\\Test.spp");
' B7 p5 [% Z' z# e' j' }}
& ^* y: M1 l$ s- G) Ncatch (e) 1 g; p1 p# p7 V; {% j
{ 4 m, K# ?6 M+ n$ W
WScript.Echo("Could not load Model!"); - G9 Y6 k4 F0 R; s) b3 n9 e; Z
WScript.Quit(); : W' b# S. Y/ [. `! T( P+ f
}
# s; T' q. i" K1 a2 y2 F - m% N7 n# _! J. J
try
' V# [" ^( t' E1 B{ ' j; f! p; ]* p* o( S' l% M
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
( y7 G+ S# T/ J* Z9 A r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 3 r. ~1 f( n5 F: z& h: t+ B
if (r == vbCancel)
. Z* x7 I4 o6 E$ ^( ?. X {
6 }8 V7 U& f7 i simple.CloseModel(); % G/ B) l) ~0 b0 ~/ [3 R# O
WScript.Quit();
9 ?" ]) M, Z; g4 }7 a } . l2 c9 B3 t! h% W% j' t7 l4 T
} , x3 D. q5 ?) z: r' o
2 n* Z; T9 `% |$ S/ Z. {" ^- e
simple.StartSimulation(".Models.Frame.EventController");
9 E' s4 C% y8 O' k. p ( V) ~6 k; n% p$ H8 G
if (simple.IsSimulationRunning())
: d8 F2 p! U8 ]% Q1 u; [" q# P WScript.Echo("Simulation is running!");
9 K6 i+ C% D% y D . s. \7 n$ d# |6 e7 S
// Wait until simulation is finished
: A* [1 A& Q5 ]- f X+ B% {/ K. Cwhile (!Finished) WScript.Sleep(2000);
( l/ V* X, z% v% j% T+ ]1 P5 x3 K
: |3 N% X+ H, A5 dsimple.CloseModel();
. K/ j! B; u+ p8 csimple.Quit(); 6 _! N8 A& ^2 l. V, F
WScript.Quit();
" b2 W6 w+ t6 w, Z! r & A# G) I* B3 s7 t" K
* Z. O6 N9 s3 d6 i- p: g# Afunction RemoteControl_SimulationFinished()
9 M/ d( q0 V' G" r# r) \3 W{
) c7 a( {! H6 P Q& c& T3 n/ ^ WScript.Echo("Simulation Finished!"); |