Example of a JScript
8 T( l' O" _1 m5 Lvar vbOKCancel = 1; ' F8 q0 t, T6 x" z
var vbCancel = 2; 7 R, O# x" g1 l' p& {8 O, ]
var vbInformation = 64; ; [4 T2 |' t4 F/ h- P j" ^( M# }
var Finished=false;
1 ]7 h; G9 ]; H6 X . o }/ a" f) Y5 u3 I
var WSHShell = new ActiveXObject("WScript.Shell"); % l+ u/ t- ]- S. x) T2 u
' {5 s) B9 g7 t* X: ~+ m0 g
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
t, Y8 R% s5 @2 x6 Y7 ~4 x9 O) u
' L0 Z$ ^" K) V. Z3 K! _' b% @' hsimple.SetLicenseType("Runtime");
2 u% y, X/ R, S# o6 T" X0 ~7 L# l 2 a2 e" k# j4 i8 ~6 V& N4 h8 m
try
7 Q7 C8 y' q, R- `8 I1 }{ % }7 x) H% Y% |( ?0 m
// Enter the path to a model file! , M; a, j( S7 j$ w0 p$ `7 q" ?% U
simple.LoadModel("C:\\Models\\Test.spp");
' U( U4 u- F+ Q) }9 P2 B0 m. u} , V1 p* j& \; f* ^* I: n0 w" m1 j
catch (e)
* A, J% h( g) F{ 7 B u$ p- I/ _& O9 z
WScript.Echo("Could not load Model!");
& U2 y% g$ H- S8 _; I1 ] WScript.Quit();
J( e c3 I" } r' r1 t4 X7 D}
4 K* C" O f( S6 k9 {
* b, Z& a; v y6 ]0 H Atry
, X1 L% C8 i: j- `{ / f7 d7 _; A: Q% x
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
& @3 R& V7 x+ t: [3 ?& o; z r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 1 Q% o6 y f1 f. b4 S# a
if (r == vbCancel)
; L' A: N% } ?2 J. c' t {
. _9 e. a" M( C, S$ e simple.CloseModel();
: Z% t3 s4 @0 K w# W7 |( e2 Y5 b9 O3 T WScript.Quit();
7 I5 O& @ n* D5 s } 9 U' b J! ^( L) z
}
" J7 L9 @4 _1 \2 ]# {. w& p7 y
* j" d: P0 ?; a1 j# Z" h% Esimple.StartSimulation(".Models.Frame.EventController");
, G# n4 G- m4 Z 0 @0 S5 L- H' A a! A
if (simple.IsSimulationRunning()) 4 b; w6 v" X& n5 y
WScript.Echo("Simulation is running!");
- U. S6 m2 a( V2 m5 y 9 v" y8 P/ X+ D6 G: t# E# J3 g
// Wait until simulation is finished
# v) H: _/ [4 \# @2 owhile (!Finished) WScript.Sleep(2000);
$ A3 B2 w. A+ v- I8 P
; |: W% y# F2 S0 G" s5 D0 f# H8 ysimple.CloseModel();
6 P5 s( O- M; g7 _simple.Quit();
. K: E# t6 z* k8 W1 N; gWScript.Quit();
/ q" b( P* u9 s" j& s
' M" f+ e. c. u& M. p' Y$ H" b ) h! z/ E; A' w( X
function RemoteControl_SimulationFinished() 1 k1 l0 R! J _! b/ d; G$ X2 a
{
) o7 G' o; k# w5 Y6 b WScript.Echo("Simulation Finished!"); |