Pointer memory, linked lists and trees.

Posted by Vinícius Dutra Aperibense on 05-Nov-2015 05:09

I wonder if I can work with progress in memory pointer . Must also create linked list , stack, queue , etc ... for a college work and do not want to do in C / C ++ language. Can anyone help me or send some sample code because I have experience in progress but never worked with memory pointer.
Thank you!

All Replies

Posted by Brian K. Maher on 05-Nov-2015 05:48

Hi,
 
You probably could but I have no sample code.  Check out the External Program Interfaces manual and look into all of the GET-* and PUT-* functions which work on MEMPTR variables.
 
Brian

Posted by Roger Blanchard on 05-Nov-2015 06:49

We have had to use a MEMPTR typically when integrating with a 3rd party dll.

The following RUN statement will make a call to MTX_GET_CashierDisplay which will return the text we are looking for. A similar approach would be used when sending info to the dll.

DEF VAR cCashierDisplay    AS CHAR    NO-UNDO.

RUN MTX_GET_CashierDisplay1 (OUTPUT cCashierDisplay).

The following are defined in a persistent procedure.

PROCEDURE MTX_POS_GET_CashierDisplay1   EXTERNAL {&MTX_POS} PERSISTENT:

   DEFINE OUTPUT   PARAMETER CashierDisplay1       AS MEMPTR                               NO-UNDO.

END PROCEDURE.

PROCEDURE MTX_GET_CashierDisplay1 :

   DEFINE OUTPUT PARAMETER pcCashierDisplay1       AS CHARACTER    NO-UNDO.

   DEFINE VARIABLE mCashierDisplay1                AS MEMPTR       NO-UNDO.

   SET-SIZE(mCashierDisplay1) = 20.

   RUN MTX_POS_GET_CashierDisplay1 (OUTPUT mCashierDisplay1).

   ASSIGN pcCashierDisplay1 = GET-STRING(mCashierDisplay1,1).

   SET-SIZE(mCashierDisplay1) = 0.

   RETURN.

END PROCEDURE.

Posted by Garry Hall on 05-Nov-2015 07:11

Do you need to interface to a DLL/shared object? Using memptrs just for the sake of using memptrs is a lot of code whose purpose would not be readily obvious to the user. If you just have to represent an abstract data type in some language, I'd probably go with OOABL objects instead, implementing an interface with Next and Previous methods/properties.

If you do have to access a DLL/shared object, take into consideration the PROCESS-ARCHITECTURE, as the size of pointers changes between 32-bit and 64-bit. You'd probably want to use at least 11.3 for this.

Posted by Laura Stern on 05-Nov-2015 08:13

I totally agree with Garry.  MEMPTRs are not the way to go.  As he said - use OO, where you would have an object instance for each node in a linked list for example.  

Posted by Brian K. Maher on 05-Nov-2015 08:16

I think he is doing this for a school class.  If I am correct using OO principals may not be allowed.

Posted by OctavioOlguin on 05-Nov-2015 10:50

I started using Progress ages ago, just to avoid using memptrs, list and trees...

All that is inherent on the 4GL part of the name, didn't?

ps.  I ended using mempointers on some two or three programs, but  then again, all tree, and list stuff, came free with 4gl...;)

Posted by scott_auge on 06-Nov-2015 14:54

Using records for the data portions for various data structures makes sense since they are in the language already.  I have a couple of data structures this way in my book available for free here amduus.com/.../

This thread is closed