Read Data from a memory pointer

Hi all,
I'm working with progress9.1ESP4.
I need a code sample to read the content of the memory pointer.
I'm getting some text value set from a memory pointer variable and I need to write these information to a text file. I's anybody have a idea of how to achieve this


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
richardkelters's picture

Read Data from a memory pointer

My code samples are too specific but you can go through the memptr byte by byte and with Progress functions like get-bytes, get-byte, get-string, put-string, etc you should be able to do your thing. Y

Be carefull with put-string: PUT-STRING method: when using PUT-STRING the Progress help tells us a null byte is added: "Stores the null-terminated value of a CHARACTER expression at the specified memory location." thus adding 0x00. Same with get-string it will return a string until the first NULL is found even though there may be more bytes/text.

Here's a code sample to read and write memptr/file.

DEFINE VARIABLE m AS MEMPTR NO-UNDO.
DEFINE VARIABLE cFileIn# AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFileOut# AS CHARACTER NO-UNDO.
cFileIn# = "file-name existing file".
cFileOut# = "new file name".
INPUT FROM VALUE(cFileIn#) BINARY NO-MAP.
SEEK INPUT TO END.
SET-SIZE(m) = SEEK(INPUT).
REPEAT:
IMPORT m.
LEAVE.
END.
INPUT CLOSE.

OUTPUT TO VALUE(cFileOut#) BINARY NO-MAP.
EXPORT m.
OUTPUT CLOSE.


Part of File

What if I only want part of the file exported?
I want to be able to search for some content and then take everything after that and export it to another file.

Dorian Chalom, Systems Analyst
Independent Bank
Mortgage Information Technologies Department
4200 East Beltline NE
Grand Rapids, MI 49525
(616)447-3900 Ext. 43033
mailto:dchalom@ibcp.com


Read Data from a memory pointer

Right on target. I did some modifications to make it work according to my requirement. thanks a lot.
cheers