next up previous contents index
Next: ACCEPT /FORMAT Up: ACCEPT Previous: ACCEPT /BINARY   Contents   Index


ACCEPT /COLUMN

        [SIC\]ACCEPT Var_1 [Var_2 [...] /COLUMN File_Name [Separator] [/FOR-
    MAT String] [/LINE L1 [L2]]

    Read  ONE or SEVERAL 1-Dimensional variables in a flexible format from a
    formatted file File_Name. Each variables can be of any  length,  from  0
    (scalar) to N. They are filled by reading each associated column, start-
    ing from first line. Data is read in as many lines as required.  If  end
    of file is reached in the meantime, an error is raised.

    Characters after a "!" are considered as comments and are ignored. Blank
    or full comment lines (starting with a "!") are  skipped.  The  starting
    line number can be selected with /LINE option.

    A * as an argument of the ACCEPT command indicates a dummy variable used
    to skip a column in the input file. For example, the command
        ACCEPT A * B C /COLUMN TEST.DAT
    reads A,B and C from columns 1,3 and 4 of file TEST.DAT, since the * in-
    dicates to skip the second column.

    Option /FORMAT can also be used to specify a fixed Fortran-like format.

    By  default,  the  format is the equivalent of the Fortran list-directed
    (*) format. In this format, character strings must be  included  between
    quotes. The default can be changed by specifying a separator as a second
    argument of option /COLUMN. The separator can be " " ( which gives a be-
    haviour  like  the  COLUMN command of GreG), or any other character. For
    example, specifying "\;" as a separator can  allow  to  read  CSV  files
    (e.g. Excel data files).

    Example of list-directed read (note the quotes are taken into account):
        SIC> type test.dat
        123 "Hello, world!" 3.14
        SIC> define integer i
        SIC> define character c*16
        SIC> define real r
        SIC> accept i c r /column test.dat
        SIC> exa i c r
        I               =          123           ! Integer GLOBAL
        C               = Hello, world!          ! Character*16 GLOBAL
        R               =    3.140000            ! Real    GLOBAL
    In most cases, a list-directed is equivalent to use space as
    separator. Only when quotes or blanks in strings are involved makes a
    difference.

    Example of blank-separated read (in this case, providing the blank
    separator or not makes no difference):
        SIC> type test.dat
        123 Hello 3.14
        SIC> accept i c r /column test.dat " "
        SIC> exa i c r
        I               =          123           ! Integer GLOBAL
        C               = Hello                  ! Character*16 GLOBAL
        R               =    3.140000            ! Real    GLOBAL

    Example  of blank-separated read (in this case, the blank separator MUST
    be given):
        SIC> type test.dat
        123 1.23" 4.56"
        SIC> define character l*12 m*12
        SIC> accept i l m /column test.dat " "
        SIC> exa i l m
        I               =          123           ! Integer GLOBAL
        L               = 1.23"                  ! Character*12 GLOBAL
        M               = 4.56"                  ! Character*12 GLOBAL


Gildas manager 2024-04-19