Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I loop through the rows in a topspeed table? 1

Status
Not open for further replies.

rleiman

Programmer
May 3, 2006
258
US
Hi Everyone,

I would like to loop through the rows in a topspeed table. I would like to initially start from a point based on a key and stay in the loop until the index value would change or the end of the table is reached.

I know it can be done with the "process" template but would like to see what the code looks like to do this.

Can you show me some example code to do this?

Thanks.

Emad
 
Emad - you didn't say if you were using ABC or not, here is a RTL (Run Time Language) version.

!Prime all components of KeyX
TableY.FieldA_InKeyX = FieldAValue
TableY.FieldB_InKeyX = FieldBValue
CLEAR(TableY.FieldC_InKeyX, -1) !see Note below

!Process the table in KeyX order (1st arg)
!Starting at the primed values in KeyX (2nd arg)
SET(TableY.KeyX, TableY.KeyX)

LOOP
NEXT(TableY)
IF TableY.FieldB_InKeyX <> FieldBValue OR |
TableY.FieldA_InKeyX <> FieldAValue OR |
ERRORCODE() |
THEN
BREAK
END
!do stuff
END

!note from FieldC
CLEAR(x,-1) set to lowest possible value.
if this key component is descending, then reverse
CLEAR(x, 1) set to highest possible value

I added FieldC to show a field that you are NOT interested on using to define the Range, that is non the less part of the key.

HTH,
Mark Goldberg
 
Hi Mark.

Thanks for the reply.

It's ABC.

Truly,
Emad
 
Hi Mark.

Thanks for the code and usefull descriptions.

I will try it tomorrow.

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top