summaryrefslogtreecommitdiff
path: root/system/base/unknown/src/STD.ELA
blob: 047db9aeef1b258e28655360bfe4c14c0dc3f50d (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
PACKET command dialogue DEFINES                (* Autor: J.Liedtke *)
                                               (* Stand:  26.04.82 *)
       command dialogue ,
       say ,
       yes ,
       no ,
       param position ,
       last param :
 
 
LET up      = ""3"" ,
    right   = ""2"" ,
    param pre  = " (""" ,
    param post = """)"13""10"" ;

TEXT VAR std param := "" ;
 
BOOL VAR dialogue flag := TRUE ;

INT VAR param x := 0 ;
 
 
BOOL PROC command dialogue :
  dialogue flag
ENDPROC command dialogue ;
 
PROC command dialogue (BOOL CONST status) :
  dialogue flag := status
ENDPROC command dialogue ;
 
 
BOOL PROC yes (TEXT CONST question) :
 
  IF dialogue flag
    THEN ask question
    ELSE TRUE
  FI .
 
ask question :
  put (question) ;
  skip previous input chars ;
  put ("(j/n) ?") ;
  get answer ;
  IF correct answer
    THEN putline (answer) ;
         positive answer
    ELSE out (""7"") ;
         LENGTH question + 9 TIMESOUT ""8"" ;
         yes (question)
  FI .
 
get answer :
  TEXT VAR answer ;
  inchar (answer) .
 
correct answer :
  pos ("jnyJNY", answer) > 0 .
 
positive answer :
  pos ("jyJY", answer) > 0 .

skip previous input chars :
  REP UNTIL incharety = "" PER .
 
ENDPROC yes ;
 
BOOL PROC no (TEXT CONST question) :
 
  NOT yes (question)
 
ENDPROC no ;
 
PROC say (TEXT CONST message) :
 
  IF dialogue flag
    THEN out (message)
  FI
 
ENDPROC say ;
 
PROC param position (INT CONST x) :
 
  param x := x

ENDPROC param position ;

TEXT PROC last param :
 
  IF param x > 0
    THEN out (up) ;
         param x TIMESOUT right ;
         out (param pre) ;
         out (std param) ;
         out (param post)
  FI ;
  std param
 
ENDPROC last param ;
 
PROC last param (TEXT CONST new) :
  std param := new
ENDPROC last param ;

ENDPACKET command dialogue ;


PACKET input DEFINES                         (* Stand: 01.05.81 *)
 
    get ,
    getline , 
    get secret line :
 
 
LET cr              = ""13"" ,
    esc             = ""27"" ,
    rubout          = ""12"" ,
    bell            = ""7"" ,
    back blank back = ""8" "8"" ,
    del line cr lf  = ""5""13""10"" ;

PROC get (TEXT VAR word) : 
 
  REP
    get (word, " ")
  UNTIL word <> "" AND word <> " " PER ;
  delete leading blanks .
 
delete leading blanks :
  WHILE (word SUB 1) = " " REP
    word := subtext (word,2)
  PER .
 
ENDPROC get ;
 
PROC get (TEXT VAR word, TEXT CONST separator) : 
 
  word := "" ;
  feldseparator (separator) ;
  editget (word) ;
  feldseparator ("") ;
  echoe last char
 
ENDPROC get ;
 
PROC echoe last char :
 
  TEXT CONST last char := feldzeichen ;
  IF last char = ""13""
    THEN out (""13""10"")
    ELSE out (last char)
  FI
 
ENDPROC echoe last char ;
 
PROC get (TEXT VAR word, INT CONST length) :
 
  word := "" ;
  feldseparator ("") ;
  editget (word, length, length) ;
  echoe last char 
 
ENDPROC get ;
 
PROC getline (TEXT VAR line ) : 
 
  line := "" ;
  feldseparator ("") ;
  editget (line) ;
  echoe last char
 
ENDPROC getline ;
 
PROC get secret line (TEXT VAR line) :

  TEXT VAR char ;
  line := "" ;
  get start cursor position ;
  get line very secret ;
  IF char = esc
    THEN get line little secret
  FI ;
  cursor to start position ;
  out (del line cr lf) .

get line very secret :
  REP
    inchar (char) ;
    IF char = esc OR char = cr
      THEN LEAVE get line very secret
    ELIF char = rubout
      THEN delete last char
    ELIF char >= " "
      THEN line CAT char ;
           out (".")
    ELSE   out (bell)
    FI
  PER .

delete last char :
  IF LENGTH line = 0
    THEN out (bell)
    ELSE out (back blank back) ;
         delete char (line, LENGTH line)
  FI .

get line little secret :
  feldseparator ("") ;
  cursor to start position ;
  editget (line) .

get start cursor position :
  INT VAR x, y; 
  get cursor (x, y) .

cursor to start position :
  cursor (x, y) .

ENDPROC get secret line ;

ENDPACKET input ;