15 years ago
Problem with global constants and case statement
I'm working in TestComplete 7 with DScript and I have the following problem with the 'case' statement.
In the source 'libVar' I have declared constants
const
TS_NOTPLANNED = 'Not Planned';
TS_PLANNED = 'Planned';
...
In the following source I use libVar but the constants in the case statement will not be known. I got the error 'Constant expression expected' for the lines in the case
statement.
uses libVar;
procedure Test;
var
TestStatus : integer;
begin
TestStatus := TS_NOTPLANNED;
case TestStatus of
TS_NOTPLANNED : Attr.BackColor := RGB(235,235,235);
TS_PLANNED : Attr.BackColor := RGB(128,255,255);
...
end;
end;
For the line 'TestStatus := TS_NOTPLANNED;' I got no error. Furthermore if I define the constants in the source where it will be used, I also get no error.
So I want to define constants global and I want to use case statements (no if statements), but it doesn't work. Has DScript a bug in this constellation?
In the source 'libVar' I have declared constants
const
TS_NOTPLANNED = 'Not Planned';
TS_PLANNED = 'Planned';
...
In the following source I use libVar but the constants in the case statement will not be known. I got the error 'Constant expression expected' for the lines in the case
statement.
uses libVar;
procedure Test;
var
TestStatus : integer;
begin
TestStatus := TS_NOTPLANNED;
case TestStatus of
TS_NOTPLANNED : Attr.BackColor := RGB(235,235,235);
TS_PLANNED : Attr.BackColor := RGB(128,255,255);
...
end;
end;
For the line 'TestStatus := TS_NOTPLANNED;' I got no error. Furthermore if I define the constants in the source where it will be used, I also get no error.
So I want to define constants global and I want to use case statements (no if statements), but it doesn't work. Has DScript a bug in this constellation?