Example of a JScript + ]- K. g+ V! o& T" @
var vbOKCancel = 1; # }- t" a& \' Y6 u$ v/ Z' }
var vbCancel = 2; 2 x4 Y5 F2 \/ d1 l* I
var vbInformation = 64;
1 C! o" c% q" j0 J" ~* ivar Finished=false;
2 l# V3 W3 h$ j/ x) l % p* Q) B# c6 K# H
var WSHShell = new ActiveXObject("WScript.Shell"); e, U+ p: p5 B2 V( ?" Y2 R' P B
! V: A* H: m; @& O6 o! qvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); : T6 [6 {; S6 q% F1 v( U9 ?
9 V A8 J: V# R( K4 G8 Q% a
simple.SetLicenseType("Runtime"); " I+ ^1 e K7 I& o
) v0 L3 Y0 i p! A9 otry ( ]4 H2 z- X3 j; F' z
{ 1 R# J, S; X P( u9 l6 m
// Enter the path to a model file!
1 S( o b C8 c' E; x& m; r+ Q* K simple.LoadModel("C:\\Models\\Test.spp"); & q" F0 E( `( F+ Q, {* c. E
} 5 E0 Y* C/ p1 }, z
catch (e)
( _- i1 d& c( x3 N5 |{
1 i% y6 q- m* n& y WScript.Echo("Could not load Model!"); + Y4 Y; C0 y& H9 z& u p7 t
WScript.Quit();
. q- U) L' {0 R* Y v} 2 p& V% r. _$ q- d1 Z" D
" u. R9 Q1 f; ztry , z8 ~+ F) K3 f5 C5 u! Q* B
{
: r/ o2 u& `' g7 |0 o2 y7 ^ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
9 g. V' a* F, I! t r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 3 |1 P# [5 y( _! j; s
if (r == vbCancel) # K! D* E; P! a. r& R
{ ( ?. z& N7 x7 w3 r8 Q
simple.CloseModel(); ( k( S: W' @. `+ i3 n
WScript.Quit(); g9 `2 E: h9 _; S) o$ H
}
- a2 j6 l$ H* L- @0 @' e) b' h} 5 D; H9 Q7 b7 d* }+ J; d' u! L
* F) H! R5 W1 D5 {9 B' B
simple.StartSimulation(".Models.Frame.EventController");
, n) P# u+ I2 _
& }5 m$ _. L' q/ n" u; s1 |- Sif (simple.IsSimulationRunning())
" g* v- X# E. Y) F9 k# c WScript.Echo("Simulation is running!");
5 E/ Z' J- {+ ~+ I: r' V ! `% |2 q7 F O% H6 Y# g
// Wait until simulation is finished
5 A0 J: M- g) i2 p, ^; r5 nwhile (!Finished) WScript.Sleep(2000);
5 h. n& ^- r6 a9 Z, {/ B
' `3 ]5 P' J3 `* C- j {+ ysimple.CloseModel(); % l5 J2 Y, g" [# B% {& r4 {
simple.Quit(); 8 [* N% v6 E x$ t) ~& |9 U( R
WScript.Quit();
& i& g, n' J% p, e
Z6 X* b j; V! v
3 K4 G: r; _+ p1 u9 `' s! Bfunction RemoteControl_SimulationFinished()
6 P- |/ L' `! `- s, S" ]7 f5 b{
$ l# F: s6 N" w. A WScript.Echo("Simulation Finished!"); |