 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Victor Guest
|
Posted: Mon Oct 23, 2006 11:13 pm Post subject: Delphi 2006 implicit type conversion problem |
|
|
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 |
|
 |
|
|
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
|
|