read from file | ||||||||||||||||||||||
Type | command | |||||||||||||||||||||
Dictionary | LCS | |||||||||||||||||||||
Library | LiveCode Script | |||||||||||||||||||||
Syntax |
| |||||||||||||||||||||
Summary | Takes data from a file that has been opened with the open file command, and places the data in the it variable. | |||||||||||||||||||||
Introduced | 1.0 | |||||||||||||||||||||
OS | mac, windows, linux, ios, android | |||||||||||||||||||||
Platforms | desktop, server, mobile | |||||||||||||||||||||
Parameters |
| |||||||||||||||||||||
Example |
| |||||||||||||||||||||
Values |
| |||||||||||||||||||||
Related | Keyword: file, characters, string, character, integer, it, URL Constant: CRLF Command: write to file, close file, open file, seek, get Function: ticks, result, milliseconds Control Structure: function Glossary: platform, binary file, variable, byte, case-sensitive, keyword, negative, expression, command, evaluate | |||||||||||||||||||||
Security | disk | |||||||||||||||||||||
Description | Use the read from file command to get data from a file.
If you specify the name of a serial port on Mac OS or Windows systems, LiveCode reads from the specified port. The names of serial ports end in a colon (:). The start specifies the character or byte position in the file where you want to begin reading. A positive number begins start characters after the beginning of the file; a negative number begins start characters before the end of the file. The string is any expression that evaluates to a string. When LiveCode encounters the string in the file, it stops reading. If the string is not encountered, the read from file command continues reading until it reaches the end of the file. If you specify any of EOF, end, or empty, the read continues reading until it reaches the end of the file. (If you're reading from a serial port, you must use the form read from file portname until empty.) The amount is a positive integer and specifies how much data to read. The chunkType is one of chars, characters, words, items, lines, int1, uInt1, int2, uint2, int4, or uint4. The read from file command reads amount of the specified chunkType. If you don't specify a chunkType, amount characters are read from the file. The time is the time to wait for the read to be completed, in milliseconds, seconds, or ticks. If you don't specify a start, LiveCode begins at the position determined by the seek command, or wherever the last read from file or write to file command to that file left off, or at the first character, if the file has not been accessed since being opened, or at the last character, if the file was opened in append mode. The until string form reads data until the specified string is encountered. The until end, until EOF, and until empty forms are synonyms, and read data up to the end of the file. You can read an entire file by opening it and reading until the end:
The read from stdin form reads from the standard input (on Unix systems). The standard input is always open, so you can read from it without first opening it.
|