How to use fopen - Protocols

This is a discussion on How to use fopen - Protocols ; What I have in mind is to say, fopen /read \%c inputfile arrayname and then start to access the array elements by, fread ... How can I exactly do this? (I was told the manual is shipped, and take 1 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to use fopen

  1. How to use fopen

    What I have in mind is to say,
    fopen /read \%c inputfile arrayname
    and then start to access the array elements by,
    fread ...
    How can I exactly do this?
    (I was told the manual is shipped, and take 1 to 2 weeks to deliver.)


    Jun


  2. Re: How to use fopen

    In article ,
    Jun Zhang wrote:
    : What I have in mind is to say,
    : fopen /read \%c inputfile arrayname
    : and then start to access the array elements by,
    : fread ...
    : How can I exactly do this?
    : (I was told the manual is shipped, and take 1 to 2 weeks to deliver.)
    :
    You have to be more specific. Do you want each line of the file to
    be assigned to an array element? Then:

    fread /line \%c \&a[\%i]

    or whatever. You don't have to wait for the manual to read about arrays
    and file i/o. See:

    http://www.columbia.edu/kermit/ckermit70.html#x7.10 (about arrays)
    http://www.columbia.edu/kermit/ckermit70.html#x1.22 (about file i/o)

    - Frank

  3. Re: How to use fopen

    fopen /read \%c inputfile
    fread \%c a

    so that each element of the array will be a field of a line in
    inputfile. Suppose a line in the inputfile is like,
    5122785633 root rootpass
    I'll have a[2] with the value 'rootpass'.
    Please correct me.


    Jun

    Frank da Cruz wrote:
    > In article ,
    > Jun Zhang wrote:
    > : What I have in mind is to say,
    > : fopen /read \%c inputfile arrayname
    > : and then start to access the array elements by,
    > : fread ...
    > : How can I exactly do this?
    > : (I was told the manual is shipped, and take 1 to 2 weeks to deliver.)
    > :
    > You have to be more specific. Do you want each line of the file to
    > be assigned to an array element? Then:
    >
    > fread /line \%c \&a[\%i]
    >
    > or whatever. You don't have to wait for the manual to read about arrays
    > and file i/o. See:
    >
    > http://www.columbia.edu/kermit/ckermit70.html#x7.10 (about arrays)
    > http://www.columbia.edu/kermit/ckermit70.html#x1.22 (about file i/o)
    >
    > - Frank



  4. Re: How to use fopen

    In article ,
    Jun Zhang wrote:
    : fopen /read \%c inputfile
    : fread \%c a
    :
    : so that each element of the array will be a field of a line in
    : inputfile. Suppose a line in the inputfile is like,
    : 5122785633 root rootpass
    : I'll have a[2] with the value 'rootpass'.
    : Please correct me.
    :
    This is not something that FREAD does. Instead you would read a line,
    and then assign its fields to an array with \fsplit():

    http://www.columbia.edu/kermit/ckermit70.html#x7.3
    http://www.columbia.edu/kermit/ckermit80.html#x8.7.2

    Read both of these references; significant improvements were made to
    \fsplit() in C-Kermit 8.0.

    Example:

    fread /line \%c record
    if fail ...
    void \fsplit(\m(record),&a)

    - Frank

+ Reply to Thread