Tilde variable, dynamic array and forEach?

Tilde variable, dynamic array and forEach?

Post by P?r Nilss » Sun, 11 Jan 1998 04:00:00



I use TextStream and TCursors to generate HTML-pages and it works very
well. The data for these pages is taken from a lot of different
tables. For each table a question is made with a tilde variable, ~s.
The answer table is then scanned and the output written to an open
HTML file.
The variable is put in by entering an id-number in a text box. It
would however be more convenient to let Paradox use an answer table
from a question made against the main table with the titles and
id-numbers for which I want to make pages.

How can I do this?

Can I use a dynamic array and forEach?

If so, can I "load" the id-numbers from the answer table into the
dynamic array?

If so, how do I set the tilde variable equal to each successive
id-number in the array?

Can somebody help me with this?

P?r Nilsson
(cut-and-paste programmer!)

 
 
 

Tilde variable, dynamic array and forEach?

Post by Mark » Mon, 12 Jan 1998 04:00:00


Par,

In reply:

Quote:> The variable is put in by entering an id-number in a text box. It
> would however be more convenient to let Paradox use an answer table
> from a question made against the main table with the titles and
> id-numbers for which I want to make pages.

> How can I do this?

> Can I use a dynamic array and forEach?

Yes, that should work although you could just SCAN the answer table with a
tcursor and grab you ID and Title values that way.

Quote:> If so, can I "load" the id-numbers from the answer table into the
> dynamic array?

Yes you can, and the best way to do that would probably be with a TCursor
SCAN.  Doing it all with a SCAN would eliminate the step of having to fill
up the dynArray.  I suppose it may end up being faster to get the values
into the dynArray and the do the FOREACH since dynArrays are fast but you
would have to test it to be sure.

Quote:

> If so, how do I set the tilde variable equal to each successive
> id-number in the array?

Do it the way you would with any variable.

var
    idVal,
    titleVal    String      ;Or whatever datatype you need.
    t             TCursor
endVar

;; Assume your query has been run.

t.open(":PRIV:ANSWER.DB")

SCAN tcAnswer           :
   idVal  = t."ID Number"
   titleVal = t."Title Name"

   ;; Now run a query with your new variable values.

ENDSCAN

Quote:

> Can somebody help me with this?

I am using a very similar process to automate the generation of hundreds of
web pages and I use inMemory TCursors whenever I can.  They are fast, and I
believe TCursor methods work reliably with them.  
http://www.mgh.org/directry/doclist.html

Let me know if you need more help.  

Mark