No announcement yet.

$SEGMENT quirks?

  • Filter
  • Time
  • Show
Clear All
new posts

  • $SEGMENT quirks?

    Hey all,

    I occasionally use $SEGMENT in my longer DOS applications. But for some odd reason the
    IDE/Compiler is fussy about where and when I can place one in my code. I often have
    to randomly place $SEGMENT (and multiple times) to get it to compile.


    Few cats act their age, while
    most just cough up furballs.
    Few cats act their age, while
    most just cough up furballs.

  • #2
    The best place to put it is the first line of an $include file.
    The $include file should contain a SUB or FUNCTION only. It's
    not a really good idea to randomly put $SEGMENT statements in
    middle of a routine.


    [This message has been edited by Mel Bishop (edited February 14, 2002).]
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.


    • #3
      As Mel suggests, it's a good idea to place $SEGMENT between major code units,
      such as SUBs or FUNCTIONs, rather than just anywhere in the middle.
      You can't use $SEGMENT within a unit, or within a structured code block
      such as FOR..NEXT, DO..LOOP, or IF..END IF. Use $SEGMENT only when you
      must-- fewer segments mean more efficient code.

      Tom Hanlin
      PowerBASIC Staff