Retrieving Arguments

#
Retrieving Arguments

To properly interface your program, you must know how to retrieve an argument from the command buffer processed by SIC. In standard SIC offers for each command up to 98 options, and for each option (or command) up to 98 arguments, the total number of arguments and options in a command line being limited to 99.

Arguments in SIC command lines are positional. The position of argument number IARG of option number IOPT of the current command is kept in SIC by means of internal pointers, By convention, argument number 0 refers to the option (or command) itself, and option number 0 to the command itself. Four standard routines are provided to decode the following type of arguments. All these routines do not modify the value of the argument if it is missing in the command buffer. They may return an error condition and output an error message if requested in this case.

              Argument Type   Routine Name
              Integer*4         SIC_I4
              Real*4            SIC_R4
              Real*8            SIC_R8
              Logical*4         SIC_L4
              Character         SIC_CH
              Character         SIC_KE           (Upcase converted keyword)
              Any               SIC_DE           (Get variable descriptor)

The first four routines routines have the following calling list

              CALL SIC_name (LINE,IOPT,IARG,Arg,PRESENT,ERROR)
    in which
              LINE        The command buffer
              IOPT        The option number (0=command)
              IARG        The argument number (0=command or option)
              Arg         The argument to be retrieved
              PRESENT     A flag indicating whether an error must occur if
                          the argument is not present in the command line
              ERROR       An error flag set in case of decoding errors,
                          or for missing argument when PRESENT is set.

SIC_CH and SIC_KE are slightly different, because they also return the length of the character string:

              CALL SIC_CH (LINE,IOPT,IARG,Arg,Larg,PRESENT,ERROR)
              CALL SIC_KE (LINE,IOPT,IARG,Arg,Larg,PRESENT,ERROR)
    where
              Larg        Integer, true length of Arg

While SIC_CH returns any character string, with implicit formatting if necessary, but no case conversion, SIC_KE returns upcase keywords.

SIC_DE is similar to the other subroutines, except it returns a variable descriptor (sic_descriptor_t) instead of a Fortran scalar value. This gives the possibility for the user to pass to the command either an explicit value (e.g. 1.23, “Hello”) or a SIC variable name of any kind and any rank, while the other subroutines above are not able to deal with non-scalar values. If the user has passed a variable name, its descriptor is returned. If he has passed an explicit value, a SIC scratch variable is created in memory: it must be destroyed at some point with a call to sic_volatile. The calling sequence is equivalent to the other subroutines:

              CALL SIC_DE (LINE,IOPT,IARG,DESC,PRESENT,ERROR)
    where
              DESC is of type(sic_descriptor_t)

Two additional routines provide a way of testing the presence of an argument SIC_PRESENT(IOPT,IARG) returns the logical value .TRUE. if the required argument is present, and SIC_LEN(IOPT,IARG) returns the actual length of the argument (0 means the argument is missing). A last routine, SIC_NARG(IOPT) indicates how many arguments are actually present for option IOPT.

Note that due to the structure of SIC vocabulary, IOPT is always the sequential number of the option as defined by the ordering in the DATA statement. Hence IOPT is not dependent on the order in which the options appear in the command buffer currently analysed.

SIC also includes some general character string manipulation routines which may be of interest in many other problems. All these routines are described more completely in section .