BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delphi 2006 implicit type conversion problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal
View previous topic :: View next topic  
Author Message
Victor
Guest





PostPosted: Mon Oct 23, 2006 11:13 pm    Post subject: Delphi 2006 implicit type conversion problem Reply with quote



I've run across a problem in Delphi 2006 implicit type conversion. I
am updating a Delphi 6 program and using Delphi 2006. In it, we
sometimes use command line parameters to run the program in a batch
type environment. If we use the -a parameter (for automatic), the
program runs automatically, and does not display the main form. To run
the program manually, you have to click on a button.

We use the following (simplified) FormCreate procedure:

procedure TfMain.FormCreate(Sender: TObject);
var
i: Integer;
begin
bUnattended := False;
Application.OnException := ApplicationException;
// check command-line parameters; if 'a', run the import
automatically
for i := 1 to ParamCount do
if LowerCase(ParamStr(i)) = '-a' then begin
bUnattended := True;
end;
end;

In Delphi 6 we have no problem with this code. However in Delphi 2006,
the comparison of the parameter to the string '-a' always fails. We
have to use the following code:

procedure TfMain.FormCreate(Sender: TObject);
var
i: Integer;
st : String;
begin
bUnattended := False;
Application.OnException := ApplicationException;
// check command-line parameters; if 'a', run the import
automatically
for i := 1 to ParamCount do
st := LowerCase(ParamStr(i));
if st = '-a' then begin
bUnattended := True;
end;
end;

The implicit type conversion appears to fail, but when I explicitly
convert LowerCase(ParamStr(i)) I don't have any problem.

The work-around is fairly simple, but I thought I'd post it FYI.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.