Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/History-variables/REXX/history-variables-1.rexx
Normal file
22
Task/History-variables/REXX/history-variables-1.rexx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*REXX program demonstrates a method to track history of assignments to a REXX variable.*/
|
||||
varSet!.=0 /*initialize the all of the VARSET!'s. */
|
||||
call varSet 'fluid',min(0,-5/2,-1) ; say 'fluid=' fluid
|
||||
call varSet 'fluid',3.14159 ; say 'fluid=' fluid
|
||||
call varSet 'fluid',' Santa Claus' ; say 'fluid=' fluid
|
||||
call varSet 'fluid',,999
|
||||
say 'There were' result "assignments (sets) for the FLUID variable."
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
varSet: arg ?x; parse arg ?z, ?v, ?L /*obtain varName, value, optional─List.*/
|
||||
if ?L=='' then do /*not la ist, so set the X variable.*/
|
||||
?_=varSet!.0.?x+1 /*bump the history count (# of SETs). */
|
||||
varSet!.0.?x=?_ /* ... and store it in the "database"*/
|
||||
varSet!.?_.?x=?v /* ... and store the SET value. */
|
||||
call value(?x),?v /*now, set the real X variable. */
|
||||
return ?v /*also, return the value for function. */
|
||||
end
|
||||
say /*show a blank line for readability. */
|
||||
do ?j=1 to ?L while ?j<=varSet!.0.?x /*display the list of "set" history. */
|
||||
say 'history entry' ?j "for var" ?z":" varSet!.?J.?x
|
||||
end /*?j*/
|
||||
return ?j-1 /*return the number of assignments. */
|
||||
40
Task/History-variables/REXX/history-variables-2.rexx
Normal file
40
Task/History-variables/REXX/history-variables-2.rexx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* REXX ***************************************************************
|
||||
* Demonstrate how the history of assignments can be kept and shown
|
||||
* 13.07.2012 Walter Pachl Rewrite of Version 1 for (my) readability
|
||||
* varset.i.varu contains the ith value assigned to var
|
||||
* varset.0.varu contains the number of assignments so far
|
||||
**********************************************************************/
|
||||
varset.=0 /*initialize the assignment count */
|
||||
|
||||
call varset 'fluid',min(0,-5/2,-1) ; say 'fluid=' fluid
|
||||
call varset 'fluid',3.14159 ; say 'fluid=' fluid
|
||||
call varset 'fluid',3.14159 ; say 'fluid=' fluid
|
||||
call varset 'fluid',' Santa Claus' ; say 'fluid=' fluid
|
||||
call varset 'FLUID',' Easter Rabbit' ; say 'fluid=' fluid
|
||||
|
||||
say 'There were' varset('fluid',,'L'),
|
||||
'assignments (sets) for the FLUID variable.'
|
||||
exit
|
||||
|
||||
varset: Procedure Expose varset.
|
||||
/**********************************************************************
|
||||
* record values assigned to var (=varu as Rexx is case insensitive)
|
||||
* Invoke with list<>'' to list the sequence of assigned values
|
||||
* and return the number of assignments made (using this routine)
|
||||
**********************************************************************/
|
||||
Parse Upper Arg varu /* name of variable in uppercase */
|
||||
Parse arg var,value,list /*varName, value, optional-List. */
|
||||
|
||||
if list='' then do /*not list, so set the X variable*/
|
||||
z=varset.0.varu+1 /*bump the history count (SETs). */
|
||||
varset.z.varu=value /* ... and store it in "database"*/
|
||||
varset.0.varu=z /*the new history count */
|
||||
call value var,value /*now assign the value to var */
|
||||
end
|
||||
else Do
|
||||
Say '' /*show blank line for readability*/
|
||||
do i=1 to varset.0.varu /*list the assignment history */
|
||||
say 'history entry' i "for var" var":" varset.i.varu
|
||||
end
|
||||
end
|
||||
Return varset.0.varu /*return the number of assignments. */
|
||||
Loading…
Add table
Add a link
Reference in a new issue