|
Hans,
If she starts off with #KEY = "", then
GET #KEY = FORMNAME.%NEXT[#KEY]
will load the key of the first record into the symbol #key.
On successive calls, the value of the next record after #key willbe
loaded into #key. When she reaches the end of the file, #key will
be blank.
HTH,
Jack
|
| Using the special field name %NEXT should get her what she wants. But
she will have to remember that %NEXT requires a valid key supplied, or a null
string. In other words, to get the key of the first record, she can do:
GET #KEY = FORMNAME.%NEXT[""]
Then, successive records can be found using:
GET #KEY = FORMNAME.%NEXT[#KEY]
But %NEXT does have a limitation that if the supplied key is not for an
existing record, it works the same as null string. Therefore,
GET #KEY = FORMNAME.%NEXT["G"]
*may not* get the next record starting with "G"; if there is no record whose key
is "G" (exactly), then this statement will be the same as the first one above.
And of course when there is no next record (i.e., you've reached end-of-
file), %NEXT returns a null string.
The alternative would be to use %SEQ_NEXT, which is almost identical to
%NEXT, except that it does not do a Rewind -- that is, it will *always* get the
next record. Where this becomes important is when you are 'Next'ing through a
key that has duplicates. %NEXT cannot handle this, since it will always do a
rewind, and get "stuck" at the point that it hits a duplicate key. %SEQ_NEXT
will work as it should -- it will process every key once, even duplicates.
F
|