Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
SADD and SSEG Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'This example creates a string and then calculates its offset and segment
'using the SADD and SSEG functions. The information is then passed to a BASIC
'SUB procedure which mimics the performance of a non-BASIC print routine.
DEFINT A-Z
'Create the string.
Text$ = ".... a few well-chosen words"
'Calculate the offset, segment and length of the string.
Offset = SADD(Text$)
Segment = SSEG(Text$)
Length = LEN(Text$)
'Pass these arguments to the print routine.
CALL printit(Segment, Offset, Length)
END
SUB printit (Segment, Offset, Length)
CLS
'Set the segment for PEEKing.
DEF SEG = Segment
FOR i = 0 TO Length - 1
'Get each character from memory, convert to ASCII, and display.
PRINT CHR$(PEEK(i + Offset));
NEXT i
END SUB