Inverting @FILEARRAY

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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
 

rconn

Administrator
Staff member
May 14, 2008
10,210
86
#2
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?
 

rconn

Administrator
Staff member
May 14, 2008
10,210
86
#4
> 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()

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
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,429
40
Albuquerque, NM
prospero.unm.edu
#6
There is no other interface to the array variables -- that's the same thing that internal commands use.
I guess I was assuming you had some internal call which returned a pointer to a given element.

Why do plugins need a special interface?
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
----- 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