SCOUG-Programming Mailing List Archives
Return to [ 16 |
November |
1998 ]
>> Next Message >>
Here's a somewhat bloated attempt at solving Mr. Skye's
question about stem variables subjected for ridicule! :-)
(Hey, we're supposed to be discussing queues here.)
/* REXX - How do you pass stem variables as parameters? */
/* Define a Global Procedure Stack */
ProgStack = 'SkyeProblem'
CALL DefineGStack ProgStack
/* Define 'object' Array 'A' and it's properties */
CALL DefineA
/* 2. Show what's in it. */
do index = 1 to A.count
say '2-' A.index
end /* I indent my "end" statements. :) */
/* 3. Now call a procedure and see if you can display and modify the values. */
call PUSHA
/* call stemvar A. Note I'm calling with "A.", not "A". "A" fails too. */
call stemvar /* Note I'm calling with "A.", not "A". "A" fails too. */
CALL POPA
/* 4. Show what's in it after returning. */
do index = 1 to 3
say '4-' A.index
end
/* 5. Now call a function and see if you can display, modify and return the val
ues. */
CALL PUSHA
/* say '5a-' stemfunc(A.) "stemfunc()" returns a value. */
say '5a-' stemfunc() /* "stemfunc()" returns a value. */
CALL POPA
/* 6. Show what's in the stem variable now. */
do index = 1 to 3
say '6-' A.index
end
Call CloseGStack ProgStack
exit
/* SUBROUTINES FOLLOW */
/* note the do-it-yourself name mangling */
stemvar:
CALL POPstemvar_SV
say "3- In StemVar ..."
say '3-' stemvar_sv.1
stemvar_sv.2 = 'New line 2'
say "3-' Exiting ..."
CALL PUSHstemvar_SV
return arg(1).
/* 'Methods' for procedure stemvar's internal array stemvar_sv */
PUSHstemvar_sv:
oldstack = RXQUEUE( 'Set', ProgStack )
QUEUE stemvar_sv.count
do SV_index = 1 to stemvar_sv.count
QUEUE stemvar_sv.sv_index
end
drop SV_index
oldstack = RXQUEUE( 'Set', oldstack )
drop oldstack
return
POPstemvar_sv:
oldstack = RXQUEUE( 'Set', ProgStack )
pull stemvar_sv.count
do SV_index = 1 to stemvar_sv.count
pull stemvar_sv.SV_index
end
drop SV_index
oldstack = RXQUEUE( 'Set', oldstack )
drop oldstack
return
stemfunc:
CALL POPstemfunc_sv
say "5- In StemFunc ..."
say '5-' stemfunc_sv.2
stemfunc_sv.2 = "Hello, World"
say "5- Exiting ..."
CALL PUSHstemfunc_sv
return stemfunc_sv.2
/* Now the 'methods' for procedure stemfunc's
internal array, stemfunc_sv */
PUSHstemfunc_sv:
oldstack = RXQUEUE( 'Set', ProgStack )
QUEUE stemfunc_sv.count
do SV_index = 1 to stemfunc_sv.count
QUEUE stemfunc_sv.sv_index
end
drop SV_index
oldstack = RXQUEUE( 'Set', oldstack )
drop oldstack
return
POPstemfunc_sv:
oldstack = RXQUEUE( 'Set', ProgStack )
pull stemfunc_sv.count
do SV_index = 1 to stemfunc_sv.count
pull stemfunc_sv.SV_index
end
drop SV_index
oldstack = RXQUEUE( 'Set', oldstack )
drop oldstack
return
/***************************************************************
define 'object' Global Procedure Stack Gstack
**********************************************************/
DefineGStack: Procedure EXPOSE ProgStack
ARG GStack
Hammer:
ProgStack = RXQUEUE( 'Create', GStack)
/* until running satisfactory, to prevent 'QUEUE' leaks
on aborted runs */
IF ProgStack >< Gstack THEN
DO
SAY 'Hammering QUEUE'
CALL RXQUEUE 'Delete', GStack
CALL RXQUEUE 'Delete', ProgStack
SIGNAL Hammer
END
SAY 'Final QUEUE is: 'ProgStack
return
CloseGStack: Procedure
arg GStack
CALL RXQUEUE 'Delete', GStack
return
/**************************************************************
define 'Object' ''Array' A'
**********************************************************/
DefineA:
/* 1. Initialize a stem variable. */
A.count = '3'
A.1 = 'Line 1'
A.2 = 'Line 2'
A.3 = 'Line 3'
return
/* Now specify some 'Methods' for array 'A' */
PUSHA:
/* It can be pushed on the Global Stack */
oldstack = RXQUEUE( 'Set', ProgStack )
QUEUE a.count
do A_index = 1 to a.count
QUEUE a.A_index
end
drop A_index
oldstack = RXQUEUE( 'Set', oldstack )
drop oldstack
return
POPA:
/* It can be popped from the Global Stack */
oldstack = RXQUEUE( 'Set', ProgStack )
pull a.count
do A_index = 1 to a.count
pull a.A_index
end
drop A_index
oldstack = RXQUEUE( 'Set', oldstack )
drop oldstack
return
=====================================================
To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-programming".
For problems, contact the list owner at
"rollin@scoug.com".
=====================================================
>> Next Message >>
Return to [ 16 |
November |
1998 ]
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|