REXX Tips & Tricks, Version 2.80


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Using variables for the stem



Variable substitution for compound variables works only for the tail (that 
is the part beginning after the first period). 
Example: 

 

  stemName = "MYSTEM"
  TailName = "MYTAIL"

  stemName.Test = "1234"
  stemName.TailName = "5678"

  say "MYSTEM.TEST       = " || MYSTEM.TEST
  say "stemName.TEST     = " || stemName.TEST

  say ""

  say "stemName.MYTAIL   = " || stemName.MYTAIL
  say "stemName.TailName = " || stemName.TailName

/* prints:
  MYSTEM.TEST       = MYSTEM.TEST
  stemName.TEST     = 1234

  stemName.MYTAIL   = 567
  stemName.TailName = 567
*/


To get around this, you can use the function <VALUE. 
Example: 

 
  stemName = "MYSTEM"
  TailName = "MYTAIL"

  call value stemName || ".TEST", "1234"
  stemName.TailName = "5678"

  say "MYSTEM.TEST       = " || MYSTEM.TEST
  say "stemName.TEST     = " || stemName.TEST

  say ""

  say "stemName.MYTAIL   = " || stemName.MYTAIL
  say "stemName.TailName = " || stemName.TailName

/* prints:
  MYSTEM.TEST       = 1234
  stemName.TEST     = STEMNAME.TEST

  stemName.MYTAIL   = 5678
  stemName.TailName = 5678
*/

 (see Using variables for the tail for the conditions of variable 
substitution for tails)   

Inf-HTML End Run - Successful