TIP: Click on subject to list as thread! ANSI
echo: delphi
to: ALL
from: BRYAN SMITH
date: 1996-10-02 11:40:00
subject: Application.Terminate fails from within 11:40:2710/02/96

Can anyone explain why Application.Terminate does not work from within a
loop ?  (Delphi 1)  I have noticed this problem several times before in
different situations.
For instance, the following code fragment was taken from the FormCreate
handler of a MainForm.  The intention is to gather up a number of individual
memos named Memo1, Memo2, etc. and to assemble them into an array.
tcmp is a TComponent, s is a string.
  for j := 1 to maxMemo do
  begin
    s := 'Memo'+IntToStr(j) ; tcmp := Self.FindComponent(s) ;
    if tcmp = nil then
    begin
      MessageDlg('Component "'+s+'" can not be found.', mtError,[mbOK],0) ;
      break ;
    end ;
    MemoRay[j] := (tcmp as TMemo) ;
  end ;
  if tcmp = nil then Application.Terminate ;
The above code halts as intented if an expected Memo is missing, but if
"break" is replaced by "Application.Terminate", then the application fails
to halt at that point, and the program ends on an error in the
"MemoRay[j] :=" line.
Note - the purpose of assembling these (basically identical) memos into an
array is to allow the first "n" (not all) to be selected at run time, and
their top, left, width, and height be assigned so that they lie side by side
and just fill the window.  The excess are made invisible.  Your ideas for
better ways to handle this situation are welcome.
--- PPoint 2.00
---------------
* Origin: Kingston, Canada (1:249/109.11)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.