bas7ex.hlp (Topic list)
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