Forum Discussion

microtech_resea's avatar
14 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?

4 Replies

  • Montikore's avatar
    Montikore
    Occasional Contributor

    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...

     

  • DHB's avatar
    DHB
    Occasional Contributor

    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.


  • Montikore's avatar
    Montikore
    Occasional Contributor

    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