pop - pop value off a variable

SYNOPSIS

<pop $&var [$index]>


DESCRIPTION
The pop function "pops" (removes) a value from $&var, at the index given by $index (default 0). The target variable must be specified with pass-by-reference syntax - i.e. $&var not $var - because it will be modified. Passing it by value would not let it be modified, which might otherwise be a silent bug - hence an error is generated if it is passed by value.

The effective $index value may be zero through one less than the number of pre-existing values of $var. Explicit negative $index values are interpreted as offsets from the end of $var, e.g. -1 is the last value. Out of range or non-integral $index values are a run-time error. An empty-string or zero-values $index is taken as the default, which is 0.


DIAGNOSTICS
The pop function returns the popped-off value in $ret.


EXAMPLE

<a name=main>
  <$var = "a" "b" "c">
  <pop $&var 1>
  After: <loop $var> $var </loop>

  ret is $ret
</a>

The output of the above example would be:

After: a c
ret is b


CAVEATS
The pop function is only valid in syntaxversion 8.


SEE ALSO
push


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.