Clib.scanf()
syntax: |
Clib.scanf(formatString, variables[, ...]) |
where: |
formatString - specifies how to read and store data in variables.
variables - list of variables to hold data input according to formatString.
|
return: |
number - input items assigned.
|
description: |
This flexible method reads input from the screen, extracts data from it by matching the string to a format string (as described below), and stores the data in the variables which follow the format string. It returns the number of input items assigned; this number may be fewer than the number of parameters requested if there was a matching failure. The format string contains character combinations that specify the type of data expected. The format string specifies the admissible input sequences, and how the input is to be converted to be assigned to the variable number of arguments passed to this function.
Characters are matched against the input as read and as it matches a portion of the format string until a % character is reached. % indicates that a value is to be read and stored to subsequent parameters following the format string. Each subsequent parameter after the format string gets the next parsed value takes from the next parameter in the list following format. A parameter specification takes this form (square brackets indicate optional fields, angled brackets indicate required fields):
%[*][width]<type>
*, width, and type may be:
• * • width • type
• d, D, i, I • u, U • o, O • x, X • f, e, E, g, G • c • s • [abc] • [^abc]
Modifies any number of parameters following the format string, setting the parameters to data according to the specifications of the format string.
|
see: |
|