int ScanFile (int fileHandle, char *formatString, targetptr1, . . . , targetptr
Performs the same basic operation as Scan, except that ScanFile reads the source data from the file you specify in the fileHandle argument.
The amount of data ScanFile reads from the file depends on the amount needed to fulfill the target format specifiers in the format string. The Using the Formatting and Scanning Functions section includes a complete discussion of ScanFile.
Input | ||||||||||||
Name | Type | Description | ||||||||||
fileHandle | integer | Specifies which file to read the data from. This is the value that OpenFile originally returned or 0. If the value is 0, ScanFile reads data from the Standard I/O window. Refer to the Using the Formatting and Scanning Functions section for more information. |
||||||||||
formatString | string | Contains format specifiers that appropriately describe the source and target data to be formatted. For the three scan functions, the target specifiers must be provided in the format string. The source specifier may be omitted, in which case the source is assumed to be %s (string). If a source data type other than string is desired, the format string must begin with the specifier of the desired source type, plus the "›" symbol, followed by the target specifiers. For example, the following calls are equivalent: x = Scan (s, "%d", i) x = Scan (s, "%s›%d", i) The following list includes common specifiers:
Because the data formatting functions can describe many complex formatting operations, refer to the Using the Formatting and Scanning Functions section to make sure you are using the proper format specifier for your application. |
||||||||||
Output | ||||||||||||
Name | Type | Description | ||||||||||
targetptr1, . . . , targetptrn | Types must match | Specifies the variables in which the scanned items will be stored. There may be up to 14 arguments. These arguments must be separated by commas. Only the value of the first argument is shown at the bottom of the control after the function panel is executed. Refer to the Using the Formatting and Scanning Functions section for more information. |
Name | Type | Description |
n | integer | Number of target format specifiers satisfied. To get the number of bytes scanned from the file, call NumFmtdBytes. If the return value is less than the number of target items, then the source did not contain the exact number and type of items specified in the format string. This function returns –1 to indicate an error in the format string or –2 to indicate an I/O error. If this value is –2, you can use GetFmtIOError to get more information about the type of error that occurred. |