Page 1 of 1

Read from hashtable

Posted: Mon Apr 04, 2005 8:16 am
by juliyas
Hi all,
i wrote routine in which i read from hashtable by :

SELECT doneFile to 1
DONE = @FALSE
Loop
Call DSLogInfo('In Loop', 'Job COntrol')
READNEXT key FROM 1 Else DONE = @TRUE
...

the readnext command read by key, but i want read 2 columns from hash where the first column is key.
How i can do it?

Thanks,
Juliya

Posted: Mon Apr 04, 2005 8:23 am
by roy
Hi,
when you readnext by key you get the reminder of the row returned without hte key value.
you might also want to go over openpath and related commands in your BASIC.pdf file in the docs directory under your installation directory.

you can also search this forum, there are previous posts for handling hash files here.

IHTH,

Posted: Mon Apr 04, 2005 8:29 am
by ArndW
Juliyas,

What Roy said is not quite right, but pretty close.

The SELECT statement will put a list of all file KEYS into memory. The READNEXT statement gets the next key value from this list until the end has been reached.

With your code you need to add another line to read the contents of the record:

Code: Select all

READ InRecord FROM doneFile, key ELSE CALL DSLogFatal('Unable to read "':key:'" from input hash file','')
Now the variable InRecord will contain a string with the record contents, with each column as it is defined in the Hash File being separated by the @FM character. So if you want the 2nd column you could use

Code: Select all

InRecord<2>
.

Posted: Mon Apr 04, 2005 8:36 am
by roy
Thanks for the correction ArndW :)
Kinda hard testing and rechecking everything, I thought I remembered correctly but I guess I mixed something up there :oops:

Posted: Mon Apr 04, 2005 8:59 am
by ArndW
Roy - no problem there, you just overlooked the SELECT memory list. We've all been-there-done-that before. :P

Posted: Mon Apr 04, 2005 8:59 am
by juliyas
thanks