import into an array.

Jeff Harrison jeffaharrison at yahoo.com
Mon Nov 1 10:04:53 PDT 2010


--- On Mon, 11/1/10, Jose Lerebours <fpgroups at gmail.com> wrote:

> From: Jose Lerebours <fpgroups at gmail.com>
> Subject: Re: import into an array.
> To: "Kroboth, Joe" <joe_kroboth at chernay.com>
> Cc: "filepro-list at lists.celestial.com" <filepro-list at lists.celestial.com>
> Date: Monday, November 1, 2010, 11:14 AM
> On Mon, Nov 1, 2010 at 10:45 AM,
> Kroboth, Joe <joe_kroboth at chernay.com>
> wrote:
> > I'm working on some import routines and was wondering
> if there anyway using the import command to load the row
> directly into an array? Or am I forced to assign each field
> manually?
> >
> > Thanks.
> 
> filePro is a single depth/dimensional array.  You
> cannot import a line
> and have the columns within that line read as subs to the
> array
> element line(0)(0) or line(0)(1) ...  You need to:
> - define your array as  dim array(####) for each
> column you intend to import
> - use import  to read file and populate your arrays
> 
> That being said, you can write code to simply load the file
> onto a
> single element array and when needed, explode the content
> to retrieve
> the column value ...
> 
> Regards,
> 
> 
> Jose Lerebours
> _______________________________________________

Here is some untested sample code.  Perhaps this will help.  Please remove the colons and supply the IF/Thens, as well as your appropriate import line where appropriate.

@once:::
::dim ary1(999); dim ary2(999):
::ct(6,.0) ' counter:
loop:::
::import ascii fil = /tmp/file.txt [enter your import options here...]:
::not fil:goto done:
::ct=ct+"1":
:ct gt "1000":msgbox "Too many Lines!"; exit:
::ary1(ct)=fil(1); ary2(ct)=fil(2) ' etc....:
::goto loop:
done:::
::' at this point you have populated your arrays:
::exit:

Adjust your array limit as appropriate as well.  I believe the maximum is 32K.

Good Luck.
Jeff Harrison
Author of JHImport and JHExport.



      


More information about the Filepro-list mailing list