As with any ABL variable, you define a MEMPTR variable using the DEFINE VARIABLE statement or the VAR statement. Unlike most other data types, MEMPTR variables also have two other features that you must initialize to use them for socket communications:

  • The size of the memory region reserved for the variable
  • The byte order that ABL is to use to interpret certain data types that you can store in the variable

Before you can read or write to a MEMPTR variable, you must set the size of memory reserved for it, in bytes, using the ABL SET-SIZE statement. Depending on your data and application, you might also have to specify the byte order for reading and writing.

Generally, when writing and reading data on a socket, the client and server must agree on the byte order so ABL can consistently interpret, on both ends, the order of bytes that comprise each data type stored in the MEMPTR region. Thus, the MEMPTR data type supports the SET-BYTE-ORDER statement and the GET-BYTE-ORDER function to set and get the byte order for a MEMPTR variable. For more information, see Introduction to External Program Interfaces.