@UserRead#

Description#

This directive indicates that there are user defined tokens which must be added to the model syntax. The ZebFront program provides a standard base of automated reading and variable management, but it is sometimes desirable to add custom reading for more complicated applications. It is preferential to use the default reading because that sets a standard and reduces dependence on the code internals.

Syntax#

@UserRead { \(~\,~\,~\,\) C++ reading code }

The routine enters with an ASCII_FILE named file, and the token string read named str. The str parameter is a non-const STRING& object. Care must thus be taken to not overwrite the string if the token is not a user defined one.

Example#

The following small example gives a hypothetical input where the model allows an external file to be used for additional vector data, or the data to be input in the material file itself:

#define VERIF if (!file.ok) INP_ERROR(&str,&file.name);
@UserRead {
   if (str=="**data_file") {
      if (!data_fname) ERROR ("Multiple filenames");
      data_fname = file.getSTRING_sl();
      return TRUE;
   } else if (str=="**localization") {
      VECTOR tmp(3);
      STRING ctl = file.getSTRING();
      while (file.ok && ctl[0]!='*') {
           tmp[0] = ctl.to_double();
           tmp[1] = file.getdouble_sl(); VERIF;
           tmp[2] = file.getdouble_sl(); VERIF;
           loc.add(tmp);
      } return TRUE;
   } return FALSE;
}

**data_file is used to load a file name, and **localization will be used to load vectors in the material file. The data file could be read in @SetUp routine if the size of data_fname is greater than zero. The total vector set will be the union of all **localization inputs and what is read from the filename.