Ask a Question

Problem with global constants and case statement

microtech_resea
Not applicable

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?
4 REPLIES 4
DHB
Occasional Contributor

RE: Problem with global constants and case statement

Hi, 


I had announced the same problem in the past (beginning of 2008, Version 6.1) and this was AQAs answer:


Hello Dirk,



The problem is caused by an issue in the DelphiScript engine which is shipped by a third-party vendor. I have registered the problem. Unfortunately, I cannot say when it will be fixed if at all. I am sorry for the inconvenience.



Best regards,

Andrew


It would be nice to see that fixed.


TC 7.52/8.70/9.20 Standard, DelphiScript

RE: Problem with global constants and case statement


Hi Alexander and Dirk,





We are planning to fix this issue in TestComplete 8.
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Montikore
Occasional Contributor

Re: Problem with global constants and case statement

Hi,

I'm facing the exact same issue... with scripts existing and running since a long time... 

I don't understand what happened, it just suddenly stopped to work, using TestComplete 12

 

What shall i do??

 

Thanks

Montikore
Occasional Contributor

Re: Problem with global constants and case statement

ok i found the issue : in one of my scripts, i'm calling a function with 2 parameters having both default value, like myfunc(); ... but using it with parenthesis breaks everything... must call it myfunc;

it should not be the case...

 

cancel
Showing results for 
Search instead for 
Did you mean: