fdds_scanf - retrieve definition from DDS dictionary


SYNOPSIS

#include <fdds.h> (fixed-format sources)
#include <f90dds.h> (free-format sources)

integer function fdds_scanf(alias, fmt, ...)

character*(*) alias
character*(*) fmt

DESCRIPTION

fdds_scanf retrieves a definition from a dictionary. The "scan" dictionary(s) must have been previously selected by fdds_dict, or related function. The name of the definition is specified by alias.

A new definition may be selected for retrieval. Multiple names, delimited by white space, may be specified by alias. If a name is specified, the "scan" dictionaries are searched. Dictionaries are scanned from bottom-to-top and right-to-left. The newest definition that matches any alias is selected. The function returns EOF, if no match is found.

The current "scan" definition is accessed, if a blank alias is specified. The value is processed, starting from the current position. The function returns EOF, if a "scan" definition is not already selected.

fdds_scanf is controlled by a format string and optional arguments. Processing begins at the current position in the definition value. Characters are matched and converted, as specified by the ANSI C standard for the stdio scanf function. The current position is advanced as the format is processed. The function returns the number of arguments converted and assigned. It returns EOF, if conversion fails prior to the first assignment.

Dictionaries may contain alias definitions. They define alternate names for "older" definitions. alias definitions are denoted by a special prefix, "alias:defn_name" or "$defn_name". The value of an alias definition is a list of alternate names.

fmt and optional arguments control the processing of definition values. The rules correspond to the scanf function in the ANSI C standard. Values should not contain "=" (unless escaped).

Format strings MUST be terminated with a null character ('\0').

The following table summarizes conversion specifiers recognized within fmt, but see the "C" manual for more detail.

fmt                     modifiers
char      Data type   h     l      L          *         I/O type
----      ---------   --------------------------------  --------------------
 u        integer     short long   longlong   suppress  unsigned
 d        integer     short long   longlong   suppress  decimal
 o        integer     short long   longlong   suppress  octal
 x        integer     short long   longlong   suppress  hexadecimal
 i        integer     short long   longlong   suppress  dec,oct,hex
 n        integer     short long   longlong   suppress  (returns # characters)
 c        characters  NA    NA     NA         suppress  (reads spaces also)
 s        string      NA    NA     NA         suppress  (skips initial spaces)
 p        pointer     NA    NA     NA         suppress
 e, f, g  real        NA    double longdouble suppress
 [...]    character   NA    NA     NA         suppress
 [^...]   character   NA    NA     NA         suppress
 %        NA          NA    NA     NA         NA        (literal "%")
        
fdds_scanf pads trailing blanks or truncates strings as needed during '%c', '%s' and '%[...]' conversion. Unlike "C", the maximum field width is not required to prevent string overflow.

EXAMPLES

!     default "alpha" to 3.14, override if defined
      alpha = 3.14
      ier = fdds_scanf('alpha', '%f\0', alpha)
 
!     retrieve beta, using defn alias
      ier = fdds_scanf('beta BETA Beta', '%s\0', beta)
 
!     retrieve mixed data types (string, integer, float)
      ier = fdds_scanf('gamma', '%s %i %f\0', s, i, r)
 
!     retrieve 1st & 2nd axis sizes
      ier  = fdds_scanf('size.axis(1)', '%i\0', nsmp)
      ier  = fdds_scanf('size.axis(2)', '%i\0', ntrc)
 
!     retrieve arbitrary number of float values
      ier = fdds_scanf('omega', '%f\0',omega(1))
      n = 0
      do while(ier.eq.1)
         n = n + 1
         ier = fdds_scanf(' ', '%f\0', omega(n+1))
      enddo

!     retrieve alias definition itself
      ier = fdds_scanf('$name', ' %s\0', alias)
    

SEE ALSO

fdds_dict Select DDS dictionary and mode
fdds_scank Retrieve a definition
fdds_scant Retrieve a definition
fdds_scantn Retrieve a definition
fdds_scanv Retrieve a definition
    

AUTHOR

R. L. Selzler, EPTG (May, 1994)