Pointers, arrays and dynamic lists on Rexx



IBM's Command List programming language & Restructured Extended Executor

Pointers, arrays and dynamic lists on Rexx

Postby hakghen » Fri May 28, 2010 3:32 am

Greetings fellow friends!

I need to present on my university a little teamwork with example of some languages using pointers, arrays and dynamic lists (for those who don't know, a kind of array that, instead of allocation a fixed ammount of memory to be used, uses the free memory to "keep" the variables' values and addresses of the next array element in memory).

People in my group are using Pascal, C, Java and etc, I, as a mainframe student, would like to use REXX, if possible (I thought of COBOL, but using pointers in COBOL, IMO is just some kind of plain madness).

But, I couldn't find anything solid to base my studies upon to create these examples. We have an exercise list with problems that we must solve with the selected languages.

Could any of you help me? Examples or even some documentation regarding the use of pointers on REXX would be very much appreciated!
[]'s,

Hakghen
User avatar
hakghen
 
Posts: 59
Joined: Thu Sep 11, 2008 8:15 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Pointers, arrays and dynamic lists on Rexx

Postby expat » Sat May 29, 2010 3:34 pm

Click HERE to access all of the manuals that you will require to do this is REXX. Look particularly at STEM variables.
expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: Pointers, arrays and dynamic lists on Rexx

Postby prino » Sat May 29, 2010 11:57 pm

/* REXX exec to demonstrate pseudo list processing                    */
/*** trace ?r ***************************************************** \| *
*               (C) Copyright Robert AH Prins, 1994-1994               *
************************************************************************
*  ------------------------------------------------------------------  *
* | Date       | By   | Remarks                                      | *
* |------------+------+----------------------------------------------| *
* |            |      |                                              | *
* |------------+------+----------------------------------------------| *
* | 1994-10-18 | RAHP | Initial version                              | *
* |------------+------+----------------------------------------------| *
************************************************************************
* LISTPROC is an exec to provide an example of how to emulate PL/I     *
* list processing in REXX.                                             *
***********************************************************************/
my_list. = 0
my_top   = 0
my_end   = 0
prv_ptr  = 0
!my_ptr  = 0

/***********************************************************************
* "Allocate" a list                                                    *
***********************************************************************/
do i = 1 to 10
  !my_ptr = !my_ptr + 1
  my_list.!my_ptr.data = substr('ABCDEFGHIJ', i, 1)

  if my_top = 0 then
    my_top = !my_ptr
  else
    my_list.my_end.my_nxt = !my_ptr

  my_list.!my_ptr.my_prv = prv_ptr
  my_end                 = !my_ptr
  prv_ptr                = !my_ptr
end

/***********************************************************************
* Print the list in forward direction                                  *
***********************************************************************/
!my_ptr = my_top
do while !my_ptr \= 0
  say '-> Item' !my_ptr 'Contents' my_list.!my_ptr.data
  !my_ptr = my_list.!my_ptr.my_nxt
end

/***********************************************************************
* Print the list in backward direction                                 *
***********************************************************************/
!my_ptr = my_end
do while !my_ptr \= 0
  say '<- Item' !my_ptr 'Contents' my_list.!my_ptr.data
  !my_ptr = my_list.!my_ptr.my_prv
end

/***********************************************************************
* "Free" the list                                                      *
***********************************************************************/
drop my_list.
my_list. = 0
my_top   = 0
my_end   = 0
prv_ptr  = 0
!my_ptr  = 0
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Re: Pointers, arrays and dynamic lists on Rexx

Postby hakghen » Mon May 31, 2010 11:01 pm

Hey there guys! Thanks for the docs and example! I'm studying them right now.

As soon as I finish the work I'm supposed to do to my university I'll post the result here ;)

Thanks once again!!!
[]'s,

Hakghen
User avatar
hakghen
 
Posts: 59
Joined: Thu Sep 11, 2008 8:15 pm
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post