:: Variable sharing
Home Specs

A REXX TAG can use a limited form of variable sharing with the RSP page. Variables may be copied (passed) to the tag buy using the "VARIABLES" special call, and returned to the RSP page by including REXX code in the tag output. The "VARIABLES" special call returns "0" (the default) or a list of REXX variable names or stem names which will be passed to the tag as the fourth argument on the "START", "BODY" (if the tag mandates it) and "END" calls. The list of variables will be passed to the tag in an interpret-ready format, so that by executing an "interpret variables" instruction all required variables will be available to the tag procedure. Please note that these variables are a copy of the RSP page variables, and not the same; altering them does not alter the corresponding RSP page variables; if you want to alter the RSP page variables, you may do so by including REXX code in the tag output. This is to say that shared variables are not exposed variables, in the REXX sense.

Limited stem sharing

Since version 1.1c, REXXTAGS incorporates a limited form of stem sharing in the shared variables support. Stem or sub-stem names (i.e, "stem." or "v." or "x.y.") can be returned by the "VARIABLES" special call. A stem is a symbol with a single perior at its end; a sub-stem is a symbol with several periods, one of them at its end (like "x.y."). The REXXTAGS compiler will evaluate "stem.0" at run-time, and incorporate "stem.N" (N=0..stem.0) and in the variables parameter.

Parameters and shared variables

Parameters are evaluated before shared variables, and the "VARIABLES" special call receives the current parameters for the current tag invocation. Therefore, it can return different shared variables, depending on the parameter list.


Here's a <sample:tag> procedure:

  1:Parse arg verb, parms, body, variables                  /* 'variables' are passed as the fourth argument          */
  2:  If verb = "VARIABLES" Then Return "X Y V."            /* Two simple variables, X and Y, and a stem V.           */
  3:  If verb = "START" Then Signal Start
  4:  ...
  5:Return 0
  7:Start: Interpret variables                              /* This makes X, Y, V.0 and V.1,...,V.N (N=V.0) available */
  9:nl = '00'x                                              /* REXXTAGS newline separator                             */
 10:Return "Some HTML code",
 11:  nl"<%",                                            /* Start REXX code                                        */
 12:  nl"x = '(some value)'",                               /* here we change the value of X                          */
 13:  nl'v.0 = 2; v.1 = "a value"; v.2 = "another value"'/* Here we change stem v.                                 */
 14:  nl"%>"                                             /* End REXX code                                          */

And sample RSP code using it:

  2:  x = 2;
  3:  y = 3;
  4:  v.0 = 0

  7:<!-- Now X and the stem V. will have changed, but Y will NOT have changed. -->

Last update: 15/06/03 at 16:48
Valid XHTML 1.0! Valid CSS!