|
Hi Leif,
Regarding pointers, I think the word "null" just means "tag bit not set"
without regard to what's in the 16 bytes of storage. So you can get a null ptr
by just not setting it (either with INIT or a pointer-setting instruction) to
point to anything. For example:
DCL SPCPTR ASPP;
CMPPTRT(B) ASPP,*/EQ(ITSNULL);
This code will take the branch (assuming something else didn't set ASPP).
If you do GENOPT(*LIST) on an RPGIII pgm that has files, you see:
DCL DD .NULLCL CHAR(1) INIT(X'FF')/*NO CONTROL LIST*/;
DCL SPCPTR .CO01001;
DCL OL .OL01001(.F01UFCB,.P01001,.CO01001);
SETSPP .CO01001,.NULLCL /*NO CONTROL LIST*/;
.CO01001 corresponds to Gene's ?NULL. It's not really a null ptr. It's a
NON-null ptr pointing to a byte of X'FF'. The IBM I/O pgms are explicitly
coded to regard a ptr pointing to X'FF' to mean "no control list was
provided". Evidently, from Gene's later post, setting ?NULL or .CO01001 to be
_actually_ null gets the same effect.
--Dave
Leif Svalgaard wrote:
> [Leif Svalgaard] One learns something new everyday from this list.
> > DCL DD NULL AUTO CHAR(1) INIT(X"FF");
> > DCL SPCPTR ?NULL AUTO INIT(NULL);
> > DCL OL IOLIST1 (?UFCB1, ?TYPE1, ?NULL) ARG;
> >
> [Leif Svalgaard] Gene, could you explain the trick you use to init
> a pointer to null? I found that DCL SPCPTR .NULL INIT(*) doesn't
> work and had to use CPYBWP .NULL, * instead. I thought that a
> null pointer was all zeroes. Not FF ?????
+---
| This is the MI Programmers Mailing List!
| To submit a new message, send your mail to MI400@midrange.com.
| To subscribe to this list send email to MI400-SUB@midrange.com.
| To unsubscribe from this list send email to MI400-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: dr2@cssas400.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.