Example of a JScript
3 P# k4 L' }' j0 I- L% Fvar vbOKCancel = 1; / Y2 o+ v2 g ]
var vbCancel = 2; 9 }3 _/ C7 f D# ]
var vbInformation = 64;
4 u& l: S* }3 e3 `$ S3 R+ x8 n6 Ovar Finished=false; ) K& O% C! o5 D/ e; `4 }! R7 T9 r: m
3 `/ `4 c" Z. U+ yvar WSHShell = new ActiveXObject("WScript.Shell"); 3 X6 V1 a. t1 Q: p4 G
' u @/ d( _! I2 pvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 1 w/ n' B* Y5 {9 s! \5 ]( J8 ]( t
# f# _5 |+ l6 ]9 Y8 {0 [
simple.SetLicenseType("Runtime");
/ o2 B# x6 Y7 a+ n% y1 V7 L" B, A% X3 b 6 d0 ~- O8 X. u% T6 |* K
try / K3 e5 [' F6 l8 I* C0 ?; d
{
6 `+ L3 @3 N: g6 \: u // Enter the path to a model file! " }8 b, v& l/ k1 J& }3 I0 u7 v
simple.LoadModel("C:\\Models\\Test.spp");
3 ~2 `& j N- k h} & H9 D3 a: |' s* R
catch (e)
3 P4 R/ m+ R; \8 _4 ? k, m{
. _1 e [' ^# n( M/ r! t WScript.Echo("Could not load Model!");
. y* V7 o! w: ?& a7 I5 V n WScript.Quit(); 7 u1 S- ^) C; u5 h( w
} : P/ |/ Q4 V: o- `4 s; [& i
0 i* K8 l. I# X* o S P) l
try : {1 K" @: A- O# u
{ 2 R7 O1 s' f, g
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 3 {; n) F/ ]* u
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ' T' J1 Q/ Z# K; `: s
if (r == vbCancel)
4 ?2 q p/ M1 W3 ?' E% L {
, Z3 ], b2 D$ R( b$ z' u3 ] simple.CloseModel(); - b. f/ d6 e/ F: x2 g2 H
WScript.Quit();
; _3 y! s. ^; H3 M/ p! O% Z } . t6 `$ F' q s) G8 z
}
+ D9 I. Z* V; \" R/ G6 \5 }
' C5 h8 g7 c; |+ Lsimple.StartSimulation(".Models.Frame.EventController");
% F B0 A$ ?, l* P2 c
: W+ H# O+ n5 s; l. {4 j- ^2 f' V! i8 Kif (simple.IsSimulationRunning())
/ [( ?0 M" R% g5 H c0 E WScript.Echo("Simulation is running!");
* z( g. U! E( B, F7 D
1 |( y+ R8 r7 @( ^// Wait until simulation is finished
0 D6 n: E4 @- w( Q. K! @- d7 Mwhile (!Finished) WScript.Sleep(2000);
% L& [' a ?* ?! {3 G7 N. m) @# [
& l% h* r% G) l3 dsimple.CloseModel();
# N1 Q9 D- E4 B0 E3 L* g: r5 Hsimple.Quit();
* }2 G+ O* J1 ]* _& A( OWScript.Quit();
# @, J0 ^0 i4 v4 V6 U3 G4 g1 ~7 o5 M
. B3 ]! A4 a% ^* r3 d
/ X1 A1 ^. |3 K1 B1 m% @function RemoteControl_SimulationFinished()
7 b( A( l5 t" l2 i6 o{
9 m2 V8 f9 r; m$ h [9 `# q8 k# L WScript.Echo("Simulation Finished!"); |