Example of a JScript
. n# Q8 s9 h+ L' A1 Ovar vbOKCancel = 1;
6 V; R( U6 j+ [6 hvar vbCancel = 2;
! e& B8 A4 E0 [. k U* kvar vbInformation = 64; 8 F5 I# v9 b4 A" i" ?& e" b2 y0 W
var Finished=false;
& W2 e7 R! V) N, \/ {, S$ K 4 P5 ?1 T; J9 q; U h- u+ D( ]
var WSHShell = new ActiveXObject("WScript.Shell");
. w; f5 V4 `6 C" O0 w" w* P
" f% U8 [! y8 Q- ]8 Yvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
3 b- E% Q$ i- B& z; x / C2 @( M8 w6 o( P( s! c; [
simple.SetLicenseType("Runtime");
' Q! {7 e5 a1 N4 _ 0 w( \' n! u- I/ ^8 ~6 d) W5 t# I
try ) F B7 \6 C0 {- L
{
% f! L+ Z0 @8 G m8 I% G. a. u // Enter the path to a model file! + J4 n9 a% c$ N) U
simple.LoadModel("C:\\Models\\Test.spp");
7 y6 n+ W% J, |. Y9 j4 d6 P$ X} + h. T- }4 l. a8 N N/ U/ ^7 H
catch (e)
8 B5 G6 G) C2 y9 X1 ?9 A{
6 g9 ^* V/ p! x* s5 |. w, ` WScript.Echo("Could not load Model!");
9 j7 u: Y; D0 g3 G: S" w WScript.Quit();
! o( Y/ F5 }( l1 }5 N} - c2 `. B$ y) S) H0 C0 w5 L
; K b" }( [" }: R$ jtry
# P4 u; p& \3 e{
$ c) v, m; @6 ~0 Q) M1 a* k simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { . m* {5 ^5 A) t- | g* V
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ! ~- k$ `) y' V- d* B: \
if (r == vbCancel)
- U% T2 H2 B: J- S { 1 p% Q6 E9 N( c& u# {
simple.CloseModel(); 3 O. ^" Z F, L* S
WScript.Quit(); * |9 F! W- r4 p' A: W& F; G
} ! P! u3 A6 ?* |, J) u
}
0 R) m& _; P/ H' j* @' m9 z
E! x' ]( [8 W4 b( v+ rsimple.StartSimulation(".Models.Frame.EventController"); - l; Q n- ]7 S7 F8 x& M% ?' `: E
: d- O4 o9 k- h$ {
if (simple.IsSimulationRunning()) 9 {3 q& d: B0 R$ i" @
WScript.Echo("Simulation is running!"); : q; j8 H. y T/ J2 q
/ i9 W. |1 S: o N6 U- W
// Wait until simulation is finished
0 T. M1 U( f, qwhile (!Finished) WScript.Sleep(2000); * l( B) q/ j1 ] C
" T' i$ ~, y) jsimple.CloseModel();
7 l$ p5 W) r- _* \4 y' fsimple.Quit(); " ]! [: [/ S/ B3 t9 Q7 U
WScript.Quit();
7 F3 g5 X4 x, t$ V9 @' N- ?6 e4 F
- q) Y$ K: x) b Y1 n & u; D+ ~6 K9 Y, @
function RemoteControl_SimulationFinished() : K! G/ e; l) z
{ 1 F2 q; ?7 ^% C" B/ k; ~$ S0 ?
WScript.Echo("Simulation Finished!"); |