Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-19-2019, 07:16 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default How Abort works in delphi5

Dear Expert,

I have two procedures in my delphi5 application as below. Kindly confirm if there goes something wrong while calling Test(1), then will it call Test(2) or Abort from Test(1) itself.

I want something like if there is some problem in Test(1), it should be aborted from then and there itself without processing Test(2).

HTML Code:
Procedure TestCase
begin
Test(1);
Test(2);

end;

Procedure Test(i : integer)
var loopCnt : integer;
vJsonStr : string;
begin
for loopCnt:=1 to 3 do
                begin
                        executeResultS3:=MoveToS3(FilePath+'\SCVF'+'\'+FileName+'.csv',S3BucketPath + bucketFolder);
                        IF (executeResultS3<0) OR (executeResultS3>32) THEN // not failed
                                break
                        ELSE IF loopCnt=3 THEN
                        BEGIN
                                vJsonStr:='{"status":"999","description":"Unable to Move Prediction File to S3"}';
                                RestPost('POST',vJsonStr);
                                Abort;
                        END;
                end;
end;
Thank you so much in advance.
__________________
Rmt
Reply With Quote
  #2  
Old 04-19-2019, 10:24 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

No, Abort will only exit the current function, there's no Absolutely Abort.
And that's normal, since this would also abort the application run loop.

There are 2 ways
- make it a function and start 2 if 1 returns true
- throw an exception (since it shouldn't proceed this is valid in my oppinion) and in your TestCase just add try..except around the calls to test
Reply With Quote
  #3  
Old 04-19-2019, 10:49 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 299
Default

Dear Norrit,

I will go with second option with Try Exception block. Thank you so much for the suggestion.

Regards
__________________
Rmt
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:32 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.