Array assignment problem - Protocols

This is a discussion on Array assignment problem - Protocols ; fopen /read \%c phonelist while true { fread /line \%c record echo "The line read in is \m(record)" ; Got "5035 rootpass", fine. void \fsplit(\m(record),&a) echo "Phonenumber is \&a[0]" ; Got "phonenumber is 3", ; instead of 5035. What's wrong? ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Array assignment problem

  1. Array assignment problem

    fopen /read \%c phonelist
    while true {
    fread /line \%c record
    echo "The line read in is \m(record)" ; Got "5035 rootpass", fine.
    void \fsplit(\m(record),&a)
    echo "Phonenumber is \&a[0]" ; Got "phonenumber is 3",
    ; instead of 5035.
    What's wrong?


    Jun


  2. Re: Array assignment problem

    In article ,
    Jun Zhang wrote:
    : fopen /read \%c phonelist
    : while true {
    : fread /line \%c record
    : echo "The line read in is \m(record)" ; Got "5035 rootpass", fine.
    : void \fsplit(\m(record),&a)
    : echo "Phonenumber is \&a[0]" ; Got "phonenumber is 3",
    : ; instead of 5035.
    : What's wrong?
    :
    As explained in the documentation, the 0th element of an array contains
    the number of elements in the array. The data elements begin at 1.

    You can see what's in an array with "show array", in this case:

    show array a

    - Frank

  3. Re: Array assignment problem

    The assignment
    \%1 = \&a[1]
    didn't take effect, since
    echo "\%1"
    give me nothing. I intended to pass \%1 as argument to DELIVER.
    Please shed me some light.

    Jun


    Frank da Cruz wrote:
    > In article ,
    > Jun Zhang wrote:
    > : fopen /read \%c phonelist
    > : while true {
    > : fread /line \%c record
    > : echo "The line read in is \m(record)" ; Got "5035 rootpass", fine.
    > : void \fsplit(\m(record),&a)
    > : echo "Phonenumber is \&a[0]" ; Got "phonenumber is 3",
    > : ; instead of 5035.
    > : What's wrong?
    > :
    > As explained in the documentation, the 0th element of an array contains
    > the number of elements in the array. The data elements begin at 1.
    >
    > You can see what's in an array with "show array", in this case:
    >
    > show array a
    >
    > - Frank



  4. Re: Array assignment problem

    In article <5MXdb.664$Rg3.532194417@newssvr11.news.prodigy.com>,
    Jun Zhang wrote:
    : The assignment
    : \%1 = \&a[1]
    : didn't take effect, since
    : echo "\%1"
    : give me nothing. I intended to pass \%1 as argument to DELIVER.
    : Please shed me some light.
    :
    There are several ways to assign values to varibles, including:

    DEFINE
    ASSIGN

    Use "help define" and "help assign" to see what the difference is.

    An alternative notation can be used similar to what you are trying to do,
    it is described here:

    http://www.columbia.edu/kermit/ckermit70.html#x7.9

    Note that to use this notation, you have to put a period before the
    variable name, and in this case you probably also want the "assign"
    operator, rather than the "define" one:

    .\%1 := \&a[1]

    This is equivalent to:

    assign \%1 \&a[1]

    - Frank

+ Reply to Thread