home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,304 of 2,978   
   Jason Burgon to robert   
   Re: continue/break loop early in Pascal?   
   12 Dec 06 16:35:33   
   
   XPost: comp.lang.pascal.delphi.misc   
   From: jaynews@ntlworld.com   
      
   "robert"  wrote in message   
   news:elmjoq$ide$1@news.albasani.net...   
   > Sorry for dummy Pascal question - I have to fumble in an old TP6.0 Pascal   
   program   
   > and I was on Pascal some 10 years ago..   
   >   
   > How can one break out / continue a loop early in Pascal - thus what is   
   "break" /   
   > "continue" / "next" / "return" in C, Python, ...   
      
   I can't remember what TP6 has, but TP7/BP7 has break, continue and exit.   
   Find yourself a copy of TP7 or BP7 on the 'Net if you don't have it already.   
      
   > And how to return early from a function / procedure?   
      
   exit   
      
   > procedure xy;   
   > begin   
   >   while True do begin   
   >      if cond1=True then ?continue?;   
   >      if cond2=True then ?break?;   
   >      if cond3=True then ?return?;   
   >   end;   
   > end;   
      
   Never, ever compare against True or False in a conditional test. Not only is   
   it needless, comparing against True can lead to some very difficult to find   
   bugs:   
      
   procedure xy;   
   begin   
     while True do   
     begin   
        if cond1 then   
          continue;   
        if cond2 then   
          break;   
        if not cond3 then   
          exit;   
     end;   
   end;   
      
   I changed the last if...then to show how to do an if...then on a False test.   
      
   > I found only the terrible "goto" in the docs. Is this all Pascal has?   
   >   
   > Also:   
   > How to jump to an absolute memory address?  jmp 0xFFFF:0xFFF0 ??   
      
   [untested]   
      
   procedure ResetComputer;   
   var   
     Reset: procedure absolute $FFFF:$FFF0;   
   begin   
     Reset;   
   end;   
      
   Note that the above will 'call', rather than 'jmp' to the absolute address.   
   It will also only work in real mode.   
      
   Jay   
      
   --   
      
   Jason Burgon - author of Graphic Vision   
   http://homepage.ntlworld.com/gvision   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca