@@ -329,41 +329,58 @@ ClassMethod WaitCommand() As %String [ ProcedureBlock = 1 ]
329
329
}
330
330
331
331
/// Starts new terminal loop. Must be called with JOB command.
332
- ClassMethod Loop (StartupRoutine As %String = " " ) As %Status
332
+ ClassMethod Loop (startupRoutine As %String = " " ) As %Status
333
333
{
334
334
if ($ZPARENT = 0 ) {
335
335
write " This method is for JOB use only."
336
336
return 0
337
337
}
338
338
open " terminal" ::" ^%X364"
339
339
use $io ::" ^" _ $ZName
340
- if (StartupRoutine '= " " ) {
341
- do $System .Util .SetInterruptEnable ($$$YES)
342
- do ##class (%Device ).ReDirectIO ($$$YES)
343
- try {
344
- do @StartupRoutine
345
- do ##class (%Device ).ReDirectIO ($$$NO)
346
- } catch {
347
- do ##class (%Device ).ReDirectIO ($$$NO)
348
- do ..SendChunk ($ZPARENT , " e" , $LISTBUILD ($NAMESPACE , $ZERROR ))
349
- }
350
- do ..SendChunk ($ZPARENT , " e" , $LISTBUILD ($NAMESPACE , " " ))
351
- return $$$OK
340
+ if (startupRoutine '= " " ) {
341
+ return ..StartupRoutine (startupRoutine )
352
342
}
353
- kill // kill any temporary variables ProcedureBlock may have
343
+ kill // Kill any temporary variables ProcedureBlock may have. Keep procedure block free of vars
354
344
for {
355
- do ##class (%Device ).ReDirectIO ($$$YES)
356
- do $System .Util .SetInterruptEnable ($$$YES)
357
- set $ZERROR = " "
345
+ do ..StartExecMode ()
358
346
try {
359
347
xecute ..WaitCommand ()
360
- use $io :: " ^ " _ $ZName
361
- } catch {}
362
- do ##class ( %Device ). ReDirectIO ($$$NO)
363
- write !! // assume that prompt takes 2 lines
364
- do ..SendChunk ( $ZPARENT , " e " , $LISTBUILD ( $NAMESPACE , $ZERROR ) )
348
+ } catch err {
349
+ do .. EndExecMode ( $ZERROR )
350
+ continue
351
+ }
352
+ do ..EndExecMode ( )
365
353
}
366
354
return $$$OK
367
355
}
368
356
357
+ ClassMethod StartupRoutine (routineName = " " ) As %Status
358
+ {
359
+ do ..StartExecMode ()
360
+ try {
361
+ do @routineName
362
+ } catch {
363
+ do ..EndExecMode ($ZERROR )
364
+ return $$$OK
365
+ }
366
+ do ..EndExecMode ()
367
+ return $$$OK
368
+ }
369
+
370
+ ClassMethod StartExecMode ()
371
+ {
372
+ write ! // Y pos shift
373
+ do ##class (%Device ).ReDirectIO ($$$YES)
374
+ do $System .Util .SetInterruptEnable ($$$YES)
375
+ }
376
+
377
+ ClassMethod EndExecMode (error = " " )
378
+ {
379
+ use $io ::" ^" _ $ZName
380
+ do $System .Util .SetInterruptEnable ($$$NO)
381
+ do ##class (%Device ).ReDirectIO ($$$NO)
382
+ write ! // Y pos shift
383
+ do ..SendChunk ($ZPARENT , " e" , $LISTBUILD ($NAMESPACE , error ))
384
+ }
385
+
369
386
}
0 commit comments