1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Inverting @FILEARRAY

Discussion in 'Suggestions' started by Steve Fabian, Oct 6, 2010.

  1. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Arrays provide many nice features. However, at this time we have no simple method to write the contents of an array into a file. Accordingly, I propose the function
    @ARRAYFILE[arrayname,filename[,w|a[,n]]]
    which would write the contents of arrayname into filename. The optional arguments would be interpreted thus:
    w write (or overwrite)
    a append
    n write n elements instead of all elements if n is less than the number of elements
    --
    Steve
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,036
    Likes Received:
    84
    How would that work with multidimensional arrays?
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,358
    Likes Received:
    39
    In a more generic direction: It might be nice if plugins had some interface to read and write array variables -- beyond calling Set_Cmd(), ExpandVariables() et al.
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,036
    Likes Received:
    84
    interface to

    ExpandVariables()

    There is no other interface to the array variables -- that's the same thing
    that internal commands use.

    Why do plugins need a special interface?

    Rex Conn
    JP Software
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,075
    Likes Received:
    30
    On Thu, 07 Oct 2010 23:21:40 -0400, rconn <> wrote:

    |Why do plugins need a special interface?

    I'm not saying plugins need a special interface, but it's precisely
    ExpandVariables() that makes getting an array into a file difficult. It's easy
    to get a file into an array regardless of what characters might be in it, but if
    you try to get an array back into a file, say with @FILEWRITE or @FILEWRITEB,
    you get errors on references to variables and variable functions ... requiring
    SETDOS /X-4 (perhaps more) ... just an extra gyration for the user.
     
  6. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,358
    Likes Received:
    39
    I guess I was assuming you had some internal call which returned a pointer to a given element.

    Special characters / recursive expansion is one difficulty. It also seems like a fairly complicated (slow) mechanism for doing complicated, repetitive tasks like searching or sorting. But if I'm asking for something which you yourself don't have, then never mind.

    How about a tweak to ExpandVariables(): If fRecurse is some magic value, say -999, then no recursive expansion is done, and no alias expansion for the first arg?
     
  7. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ----- Original Message -----
    From: rconn
    To: ESFabian@comcast.net
    Sent: Thursday, 2010. October 7. 07:44
    Subject: RE: [Suggestions-t-2345] Re: Inverting @FILEARRAY


    Quote:
    Originally Posted by Steve F�bi�n
    Arrays provide many nice features. However, at this time we have no simple method to write the contents of an array into a file. Accordingly, I propose the function
    @ARRAYFILE[arrayname,filename[,w|a[,n]]]
    which would write the contents of arrayname into filename. The optional arguments would be interpreted thus:
    w write (or overwrite)
    a append
    n write n elements instead of all elements if n is less than the number of elements
    --
    Steve

    How would that work with multidimensional arrays?

    It need not, the same way as @filearray and @execarray are restricted to one-dimensional arrays.
    --
    Steve
     

Share This Page