Written by

Laboratorio Echevarne
Question Paco Cadenas · 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

Comments

Julius Kavay · Dec 16, 2022

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:20ElseDoQuit;;;;  comando else aplicado a read.
    . Use0Write !!!,"Expired time."If$c(R)="a"d
    . Use0Write !!!,"A letter a has been read."
    . Quitwrite !,"If there are more lines, they will be executed",!
    quit// LITTLE BIT MODERN VERSION// Use ficnewRead *R:20If$Test {
    Use0Write !!!,"One character read"Quit
    }
    Else {
    Use0Write !!!,"Expired time."
    }
    write !,"If there are more lines, they will be executed",!
    quit

now let run both of them...

do old // let the timeout occurdo old // now with some inputdonew// let the timeout occurdonew// 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)

0
Paco Cadenas  Dec 19, 2022 to Julius Kavay

You're right of course, thanks!!!

The main thing I want is to avoid that "else" old format on "read"'s ... thinkin' in an "automatic parser" to translate old code but it seems a bit complex due to this particularities.

0
Steven Hobbs · Dec 16, 2022

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
 

0
Paco Cadenas  Dec 19, 2022 to Steven Hobbs

Thanks Steven, that's right :)

0