Initializing help system before first use

XPRBreadlinecb

XPRBreadlinecb


Purpose
Read a fixed-format line from a data file.
Synopsis
int XPRBreadlinecb(char *(*fgs)(char *,int,void *), void *file, int length, const char *format, ...);
Arguments
fgs 
The system's fgets function (defined by XPRB_FGETS).
file 
Pointer to a data file.
length 
Maximum length of any text string to be read.
format 
String indicating the format of the data line to be read, which may be one of:
t[num] 
text up to next separator sign or space (blank / tab / line break), optionally followed by the maximum string length to be read;
s[num] 
text marked by single quotes, ' ', optionally followed by the maximum string length to be read;
S[num] 
text marked by double quotes, " ", optionally followed by the maximum string length to be read;
T[num] 
text as for t, s, or S, depending on the first character read, optionally followed by the maximum string length to be read;
integer value;
real (float) value.
The number of format parameters is arbitrary.
... 
Addresses of items that are to be read, separated by commas.
Return value
Number of data items read.
Example
The following opens a data file for reading, reads a line with text and a double value, separated by a semi-colon, and then reads a line with two integers and a string of up to ten characters marked by single quotes, all separated by blanks, before finally closing the file.
double value;
FILE *datafile;
char name[100];
int i[2];
   ...
datafile=fopen("filename", "r");
XPRBreadlinecb(XPRB_FGETS, datafile, 99, "T;g", name, &value);
XPRBreadlinecb(XPRB_FGETS, datafile, 50, "i i s[10]", &i[0],
               &i[1], name);
fclose(datafile);
Further information
This function reads input data files in a format compatible with the diskdata command of mp-model and Mosel. Data lines in the input file may be continued over several lines by using the line continuation sign &. The input file may also contain comments (preceded by !) and empty lines, both of which are skipped over. The data file is accessed with standard C functions ( fopen, fclose). The format string gives the type of data item to be read. Each string type may (optionally) be followed by the maximum length to be read. Otherwise, the maximum length is assumed to be length. The type of separator signs ( e.g. , ; :) used in the data file needs to be indicated between each pair of format options. As with the C functions printf or scanf, the format string is followed by the addresses where the data are stored. With function XPRBsetdecsign the decimal sign used in the data input may be changed, for instance to use a decimal comma.
Related topics

© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.