Re: When should I switch from a dynamic array to a work file?



I would suggest that you are trying to solve the wrong problem here.

Can you not change the program to output each line in the required format on
a line by line basis? The only pain would be if it was to a printer of some
kind you need to keep track of the print line number you are on and handle
the pagination yourself.

That would be preferable to either using an array or work file.

Just a suggestion

Bag***


"yacadoo" <yacadoo@xxxxxxx> wrote in message
news:1182960415.200302.227890@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jun 27, 10:15 am, mike ryder <mg.ry...@xxxxxxxxx> wrote:
On Jun 27, 3:59 pm, yacadoo <yaca...@xxxxxxx> wrote:

Hello,

I am new to Pick and have a question about good programming practices
when deciding to use a dynamic array vs a work file. Should I switch
to using a work file if my dynamic array gets over X number of
attribute marks long or X number of bytes? Or should I just wait until
my program bogs down the system? :D What do you guys normally do?

Thanks,
Jason

That really is a complex question and will depend on what you are
doing and which flavour of Pick you are using. In simple terms, an
array is stored in memory and, as you add fields (attributes), the
inserting will take longer and longer (probably need to be over 10MB
before you even notice but that will also depend on Pick flavour,
amount of memory available and OS).

Generally (1) - MYVALUE := FM:NEWVAL is less memory intensive than
MYVALUE<12179> = NEWVAL or MYVALUE<-1> = NEWVAL
Generally (2) - READNEXT and REMOVE are more efficient constructs than
referencing the FM or VM of the array - although for jBase this is not
true and extracting the field is faster than REMOVE.
Generally (3) - for a structure, where you are using an array, you
would never use a workfile.

As you can see, these are all "generally" and the specifics of your
application or interface requirements may mean that you use
exceptional coding methods. If in doubt, build some experimental code
with a timer to see how much of a difference it makes.

hth
Mike

We are on UniVerse 10 running on Windows. I don't know how much
memory, I'm a newbie to this department and programming in general.

This question is a result of a large detail report that a client will
use. It would contain names and addresses along with other account
specific details. I have been using a new template program that I
wrote that uses a generic array that will translate the report data to
fixed width format for display on a computer crt screen or xml so it
can be exported to pdf, xls. Then on some occasions I create a
sequential file for mail merge files (csv/text).

This has been working fine for the smaller reports but now I think I
need to add logic to determine if it should use a work file instead. I
suppose I could check @SELECTED and as a general rule if it is over
500 or 1000 then use a work file instead.

I have been using MYVALUE<-1> = NEWVAL in these reports, I'll change
it to MYVALUE := FM:NEWVAL for now on, thanks for the tip.

Jason



.