advr.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.
DEF SEG Statement Details
  Summary  Details  Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 DEF SEG [ = address]
 
 Usage Notes
   ■ The address is a numeric expression with an unsigned integer value
     between 0 and 65,535, inclusive. DEF SEG sets the current segment to
     this value. If you use a value outside this range, Visual 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, Visual 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$)
 
     See: SSEG Function  VARSEG Function
 
   ■ Do not use DEF SEG to set the segment of an expanded-memory array. If
     you start Visual Basic (VBDOS.EXE) with the /Ea switch, any of the
     following 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
     See: VBDOS Command-Line Options
 
   ■ If you want to use DEF SEG to set the segment of an array, first start
     Visual Basic (VBDOS.EXE) without the /Ea switch. Note: Without the /Ea
     switch, no arrays are stored in expanded memory.