ex.hlp (Topic list)
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 Functions 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.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 DECLARE SUB printit (Segment%, Offset%, Length%)
 DEFINT A-Z
 Text$ = ".... a few well-chosen words"     ' Create the string
 
' 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
     DEF SEG = Segment                      ' Set the segment for peeking
     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