CompuServe Messages

#FastFileIO

#: 117127 S12/Modula-2Forum unknown
    02-Apr-88 12:44:41
Sb: #117032-#FastFileIO
Fm: Steve Faiwiszewski 74106,425
To: Jim Vogel 73177,441

This message turned up in search, but its forum couldn’t be identified from the original transcript, so it may not be linked into its thread.

A pointer is really nothing but an address. Your question brings up the reason why Modula-2 does not let you normally increment a pointer, because you run into all sorts of problems (like whether it's a pointer to bytes, to words, or to longwords). This can be quite dangerous in languages that do allow you to do that (such as C). To accomplish this in M2, you gotta cast (i.e. type transfer) to LONGCARD first, then increment that, and then cast back to pointer. The amount you increment decides how far the pointer was bumped. For example: VAR lc : LONGCARD; charptr : POINTER TO CHAR; intptr : POINTER TO INTEGER; BEGIN lc := LONGCARD(charptr); INC(lc); charptr := ADDRESS(lc); (* just bumped charptr to next byte *) lc := LONGCARD(intptr); INC(lc,2); (* TSIZE(INTEGER) = 2 *) intptr := ADDRESS(lc); (* bumped intptr to next integer *) Hope this helps. – Steve –