Current Help System: Tutor Translator (View Core Help)

### Text File Management

Tutor allows I/O on 4 text files identified by F0 through F4.

OPENF (F0,"FileToOpen.txt”) translates to è

IF/E.F0.NAME <> "NONE"
COMMENT/OPER,"FILE E.F0 ALREADY OPEN"
END_IF/

ELSE/
ASSIGN/E.F0.NAME = "FileToOpen.txt"
ASSIGN/E.F0.OPEN = "NO"
END_ELSE/

OPENF (F0,"FileToOpen.txt”, APPEND) translates to è

IF/E.F0.NAME <> "NONE"
COMMENT/OPER,"FILE F0 ALREADY OPEN"
END_IF/

ELSE/
ASSIGN/E.F0.NAME = "FileToOpen.txt"
E.F0.PTR =FILE/OPEN,E.F0.NAME,APPEND
ASSIGN/E.F0.OPEN = "A"
END_ELSE/

RESET(F0,Status) translates to è

IF/E.F0.OPEN <> "A"

STS =FILE/EXISTS,E.F0.NAME

IF/STS <> 0
ASSIGN/STATUS = 0
END_IF/

ELSE/
ASSIGN/STATUS = 1
END_ELSE/

IF/E.F0.OPEN <> "NO"
FILE/CLOSE,E.F0.PTR
ASSIGN/E.F0.OPEN = "NO"
END_IF/

IF/STS<>0
E.F0.PTR =FILE/OPEN,E.F0.NAME,READ
ASSIGN/E.F0.OPEN = "R"
END_IF/

ELSE/
ASSIGN/E.F0.NAME = ”r;NONE”
END_ELSE/
END_IF/

RESET(F0) translates to è

IF/E.F0.OPEN <> "A"

STS =FILE/EXISTS,E.F0.NAME

IF/E.F0.OPEN <> "NO"
FILE/CLOSE,E.F0.PTR
ASSIGN/E.F0.OPEN = "NO"
END_IF/

IF/STS<>0
E.F0.PTR =FILE/OPEN,E.F0.NAME,READ
ASSIGN/E.F0.OPEN = "R"
END_IF/

ELSE/
ASSIGN/E.F0.NAME = ”r;NONE”
END_ELSE/
END_IF/

READ (F0,IntVar, RealVar, RealVar1, BoolVar, StringVar) translates to è

E.INTVAR =FILE/READ_UPTO,E.F0.PTR," "
E.REALVAR =FILE/READ_UPTO,E.F0.PTR," "
E.REALVAR1 =FILE/READ_UPTO,E.F0.PTR," "
E.STRINGVAR =FILE/READ_UPTO,E.F0.PTR," "
E.BOOLSTR =FILE/READ_UPTO,E.F0.PTR," "
ASSIGN/ E.BOOLVAR = EQUAL(E.BOOLSTR,"True")

READLN (F0,IntVar, RealVar) translates to è

E.INTVAR =FILE/READ_UPTO,E.F0.PTR," "
E.REALVAR =FILE/READ_UPTO,E.F0.PTR," "
VRES =FILE/READLINE,E.F0.PTR,{DUMMY}

REWRITE (F0) translates to è

IF/E.F0.OPEN <> "A"
IF/E.F0.OPEN <> "NO"
FILE/CLOSE,E.F0.PTR
ASSIGN/E.F0.OPEN = "NO"
END_IF/

ELSE/
E.F0.PTR =FILE/OPEN,E.F0.NAME,WRITE
ASSIGN/E.F0.OPEN = "W"
END_ELSE/
END_IF/

write (F0," ",IntVar," ",RealVar," ",VECTVAR," ",BoolVar," ",StringVar) translates to è

ASSIGN/STRTOWRITE = FORMAT("%d", E.INTVAR)+" "+FORMAT("%f", E.REALVAR)+" "+ FORMAT("%f %f %f", E.VECT_VAR)+ " "+ E.BOOLVAL(E.BOOLVAR)+" "+ E.STRINGVAR
FILE/WRITE_BLOCK,E.F0.PTR,STRTOWRITE

Where the values are defined as:

- INT_VAR is a variable of type integer.

- REAL_VAR is a variable of type Real.

- BOOLVAR is a variable of type Boolean.

- VECT_VAR is a variable of type Vector.

writeLN (F0," ",IntVar," ",RealVar) translates to è

ASSIGN/STRTOWRITE = FORMAT(" "+"%d", E.INTVAR)+" "+FORMAT("%f", E.REALVAR)
FILE/WRITELINE,E.F0.PTR,STRTOWRITE

Where the values are defined as:

- INT_VAR is a variable of type integer.

- REAL_VAR is a variable of type Real.

CLOSEF(F0) translates to è

IF/E.F0.OPEN <> "NO"
FILE/CLOSE,E.F0.PTR
ASSIGN/E.F0.OPEN = "NO"
ASSIGN/E.F0.NAME = "NONE"
END_IF/
FILE/CLOSE,E.F0.PTR

The OPENF, READ, READLN, RESET, REWRITE, WRITE, WRITELN and CLOSEF text file commands listed before refer to E.F0 file ID. The same commands for file F1, F2 and F3 IDs E.F0 ID is replaced with the proper ID.