Question
· Dec 16, 2022

Dot cleaning...

Hi!

I'm trying to clean some dots from old stuff, do you think this two versions of code works the same way ? :

 

DOT VERSION
 Use fic

Read *R:20 Else  Do  Quit    ;;;;  comando else aplicado a read.
  Use Write !!!,"Expired time."
 If $c(R)="a" d
  Use Write !!!,"A letter a has been read."
  Quit
 


LITTLE BIT MODERN VERSION


 Use fic
 Read *R:20
 If $Test {
Use Write !!!,"One character read"
Quit
 }
 Else {
Use Write !!!,"Expired time."
 }
 

 

Thanks!

Product version: IRIS 2019.1
Discussion (4)2
Log in or sign up to continue

Is NOT the same. You can it prove by adding a label to the line with the read command and a new line at the end

    // DOT VERSION
    // Use fic
old Read *R:20 Else  Do  Quit    ;;;;  comando else aplicado a read.
    . Use 0 Write !!!,"Expired time."
    If $c(R)="a" d
    . Use 0 Write !!!,"A letter a has been read."
    . Quit
    write !,"If there are more lines, they will be executed",!
    quit

    // LITTLE BIT MODERN VERSION
    // Use fic
new Read *R:20
    If $Test {
    Use 0 Write !!!,"One character read"
    Quit
    }
    Else {
    Use 0 Write !!!,"Expired time."
    }
    write !,"If there are more lines, they will be executed",!
    quit
 

now let run both of them...

do old // let the timeout occur
do old // now with some input
do new // let the timeout occur
do new // now with some input

Do you see the difference? If there are more lines (at end) they will be executed in opposite cases (timeout/notimeout)

Another translation is

 Read *R:20
 ;; Test error case

 If '$Test { Use Write !!!,"Expired time." Quit }
 ;; Test character "a" case

 If $c(R)="a" {
   Use Write !!!,"A letter a has been read."
   Quit
 }
 ;; I added more code here to demonstrate "fall through" in original
 ;; when neither timeout nor "a" occurs
 Use 0
 Write !,"A character other than ""a"" was read"
 Quit

 ;; Since all 3 cases execute Use 0, this statement can be placed after Read and the other 3 copies deleted