File: distant.st

package info (click to toggle)
steptalk 0.10.0%2Bgit20200629-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,732 kB
  • sloc: objc: 12,182; yacc: 400; makefile: 40; sh: 34; csh: 4; awk: 3; lisp: 3
file content (46 lines) | stat: -rw-r--r-- 1,432 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
" Distant environment example 
    
    Date: 2005 Aug 17
    Author: Stefan Urbanek
    
    Usage: 
        1. run: stenvironment -name test
        2. run: stexec distant.st
        3. repeat step 2. as many times as you like
    
    Step 1. creates a scripting environment. Step 2. executes this script.

"

"Create a conversation with distant environment"
conversation := (STDistantConversation alloc) initWithEnvironmentName:'test'
                                                                 host:nil
                                                             language:nil.

Transcript showLine: '-- Conversation created:', (conversation description).

"Interpret some scripts in the distant environment"
conversation interpretScript:'Transcript showLine:\'Hello StepTalk!\'.'.
conversation interpretScript:'Environment class description'.

"Get run count"

conversation interpretScript:'runCount'.
result := conversation resultByCopy.

"If there is no run count, then we are running first time and we have to 
 define and set the run count to 1"
 
result ifNil:
    [
    Transcript showLine: ('This script was run for first time.').
        conversation interpretScript:'runCount := 0'.
        result := 1.
    ].
    
conversation interpretScript:'runCount := runCount + 1'.
result := conversation resultByCopy.

Transcript showLine: ('This script was run ', (result description), ' times.').

conversation close.