bas7advr.hlp (Topic list)
DEF SEG Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
DEF SEG sets the current segment address for a subsequent PEEK function,
Absolute routine, or BLOAD, BSAVE, or POKE statement. DEF SEG remains
in effect until changed.
 
DEF SEG [=address]
 
Usage Notes
    ■ The address is a numeric expression with an unsigned integer value
      between 0 and 65,535. DEF SEG sets the current segment to this
      value. If you use a value outside this range, BASIC generates the
      error message, "Illegal function call." The previous segment is
      retained if an error occurs.
    ■ To reset the current segment to the default data segment (DGROUP),
      use DEF SEG without any argument.
    ■ Be sure to separate DEF and SEG with a space. Otherwise, BASIC
      interprets the statement to mean "assign a value to the variable
      DEFSEG."
    ■ To set the current segment address to the address of data stored
      in far memory, you can use DEF SEG with the SSEG or VARSEG
      functions (SSEG returns the current segment address of a string;
      VARSEG returns the current segment address of numeric data). For
      example, this statement sets the current address for a far string
      named a$:
 
        DEF SEG = SSEG(a$)
 
DEF SEG and Expanded-Memory Arrays
    ■ Do not use DEF SEG to set the segment of an expanded-memory array.
      If you start QBX with the /Ea switch, any of these arrays may be
      stored in expanded memory:
        -  Numeric arrays < 16K in size
        -  Fixed-length string arrays < 16K in size
        -  User-defined-type arrays < 16K in size
    ■ If you want to use DEF SEG to set the segment of an array, first
      start QBX without the /Ea switch. (Without the /Ea switch, no arrays
      are stored in expanded memory.)
    ■ For more information on using expanded memory, see
      Using Expanded Memory.
 
Programming With OS/2 Protected Mode
    ■ When using DEF SEG in OS/2 protected mode, any DEF SEG must refer
      only to a valid selector. The DEF SEG statement itself does not
      generate any memory references using the selector, nor does it
      attempt to validate the selector. If a misdirected DEF SEG
      statement causes your program to refer to an illegal memory
      address, the operating system may generate a protection exception,
      or BASIC may generate the error message, "Permission denied." The
      default DEF SEG segment always constitutes a valid memory
      reference. Use caution when altering this reference in
      protected mode.
 
Differences from BASICA
    ■ In this version of BASIC, the CALL and CALLS statements do not
      use the segment address set by DEF SEG.