Loading...
 

Read

Read

Read(n, delimiter), Read(, delimiter)

parameters: number of blocks n (default value n=1), list of block end characters

Stack
Stack Position Description
Stack(In) -
Stack(Out) Top Character string n
Top 1 Character string n-1
. . . . . .
Stack(Out) Return value

N character strings (separated by the transferred separator=delimiter) are read.
A character string ends with one of the separators specified in the first parameter.

Each character string up to the separator therefore appears as one entry on the stack after the call.

So if you always want to read one line from a file, you can use the following line within a loop:

Read(1, "\n")

So always one line is read out. The next time this line is executed, the system automatically takes the next line.
Attention: Of course you have to program the end of the loop yourself!(See example)

Read(n), Read

Parameter: maximum block length n (default value n=200)

Stack
Stack Position Description
Stack(In) Top -
Stack(Out) Top Character string

n characters are read in (once).

Note: An input file (mode "r") must first be opened with Open.

Example:

Var(data, valid)

// Open the text file in mode "r"=read

"C:\\Temp.log" Open(, "r")

"" -> data
FALSE -> valid
 

// Create the loop for getting one line after another

do

  // Read all characters until the first \n will be found!

  Read(1, "\n")

  // If nothing is found, break the loop!

  Dup if

  {
    // Check something...

    Dup "Zeile" StringFind if

    {
      TRUE -> valid
    }
    // Add the read data to the string

    "\n" + data + -> data
  }

  else

  {
    // Break the loop if nothing returned by "Read"

    Drop break
  }
loop

// Close the file again

Close