Example of a JScript
/ a9 j* Z+ u& [, D/ m# W7 ?var vbOKCancel = 1; 8 L/ v" T# `7 H; M- I
var vbCancel = 2;
! C: e2 B4 f6 evar vbInformation = 64;
* G0 z: E4 O' z/ Mvar Finished=false;
) E. U5 M$ B9 u( r/ o. @- j
6 G" p1 Y; l! I4 wvar WSHShell = new ActiveXObject("WScript.Shell");
7 k5 L# E. V9 r Z1 D$ U
0 M h( N* h+ n# c4 E) ]var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
1 U3 M v" h/ Y" N& Q p2 Z 0 x9 ~5 h9 ^- D s+ u3 j
simple.SetLicenseType("Runtime");
) ^6 |3 R: O8 N4 T# j" T 9 t) s; [6 _" M0 g' w+ J
try
- Q7 l x+ N) t+ ?{ $ P, u. \0 F- R- r; w* p6 x. V+ ]; j
// Enter the path to a model file! / M% _" Q& M1 n! r+ k
simple.LoadModel("C:\\Models\\Test.spp"); + Q% H& Y. Z& X
}
" p! n& V P) z' Vcatch (e)
4 c& Q; g) B: x; Y{
$ {0 j, l4 A/ b: w% ~0 { WScript.Echo("Could not load Model!");
9 f6 m, l0 _ _. t7 _" ] WScript.Quit();
9 y5 x; ]4 G% u- T2 |}
3 g0 z9 _$ ^" v1 t' F- ^
v' X+ E$ w$ C& D1 S. @try 0 {& F1 W! E; P4 Z5 ~4 p9 F! e
{ 6 J; Z I1 T" H! B; a- t3 X H
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
# @+ b$ f9 ` ^4 a3 j; C% l3 p r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); / J* V# Z4 x3 L9 f
if (r == vbCancel) " [' v+ ~: g1 j* ^
{ 1 k- K8 m/ V/ F6 n# D. F7 C& ~
simple.CloseModel(); 4 ]1 V" c, u* z5 G, q/ i
WScript.Quit(); 2 g3 U* }) ?; Z
}
# i# B& _; ?, L' f9 I& ~3 r}
( F- v. D2 ]. C; E! a
! o) U8 u# H, a8 B& e6 f' X/ C, ]# Ksimple.StartSimulation(".Models.Frame.EventController"); 1 @' X* |% H" w# M# c
; A0 w; Z2 ^ m; H- ?
if (simple.IsSimulationRunning())
! b0 s3 R8 A, H2 R, c) h WScript.Echo("Simulation is running!");
8 m* C) p, o2 V: ~/ S* q# E & w9 E! X5 Y* n" W$ [ P
// Wait until simulation is finished
) t# F2 o& v [' P4 B& ^while (!Finished) WScript.Sleep(2000);
* @6 o+ s6 U- F; F* k
& v" T5 y' s- f8 K3 l; Tsimple.CloseModel(); ! N* z- _ l1 `/ ]" \$ m- W1 n5 J
simple.Quit();
' s. u4 G- ^6 P% C0 q% ZWScript.Quit();
; S0 ~' G. a( C% r4 B8 j* x) p 8 k6 m8 q& V; w% A3 `
: l# Q% ~" Z4 }' k! U+ ]function RemoteControl_SimulationFinished()
" l' @: Q9 z5 l- a4 ?- Q7 S{ 8 T7 T7 g. H5 Y. S2 m
WScript.Echo("Simulation Finished!"); |