Enumerating Fields in a GROUP or QUEUE - How do you know you've reached the end?


#21

I wrote a testbed to show that Jeff’s information is correct.

  PROGRAM
  MAP
  END

Q1 QUEUE
Str  &CSTRING
   END

Q2 QUEUE
Str &CSTRING
   END 

What:String4 STRING(4)
What:Long    LONG,OVER(What:String4)

  CODE
  ! Show it's too early for this work, as Q1.Str is NULL
  What:String4   = WHAT(Q1, 1)
  Q2.Str        &= What:Long + 0 

  Q1.STR   &= NEW CSTRING(42)
  Q1.STR    = 'Hi Dennis'
  DO ShowValues

  ! now set Q2.Str to the referenc in Q1.Str
  What:String4 = WHAT(Q1, 1)
  Q2.Str      &= What:Long + 0 ! + 0 turns this into an expression, so it's an address
  DO ShowValues

  Q1.STR = 'New Value'
  DO ShowValues

           !         1         2         3         4
           !123456789-123456789-123456789-123456789-123456789-
  Q1.STR = 'This is a longer value than the orig, and > 42'
  DO ShowValues

ShowValues ROUTINE
  MESSAGE('Q1.Str  ['& Q1.Str &']' |
       & '|Q2.Field['& Q2.Str &']' |
         )

#22

Cool, Mark. Glad it’s making sense.

Don’t forget to DISPOSE() before you go to production. :slight_smile: