Page 1 of 1

if statement that works in debug but not in run

Posted: Fri Jul 20, 2007 5:50 pm
by Ryan Lee
I have the following statements:

Code: Select all

Set Variable ISSERVICERUNNING to
Check Service State for MyService (write result into variable ISSERVICERUNNING)
MessageBox: $TITLE$, service: $ISSERVICERUNNING$
if Variable $ISSERVICERUNNING$ Equals RUNNING
  MessageBox: $TITLE$, in if block
end


When I debug with MyService running, I get a message box stating that the service is RUNNING and I go into my if block (pops up another message box).

When I run with MyService running, I get a message box stating that the service is RUNNING but I do not go into my second if block (no message box stating i'm in the if block).

Posted: Fri Jul 20, 2007 6:16 pm
by MichaelNesmith
The IDE already warns you about this (unless you turned tips off), but don't use $ signs in fields where variables are already expected:

Code: Select all

if Variable $ISSERVICERUNNING$


is wrong;

Code: Select all

if Variable ISSERVICERUNNING


is correct.

Posted: Fri Jul 20, 2007 7:55 pm
by Ryan Lee
My bad copying the code into this post.

Code: Select all

Set Variable ISSERVICERUNNING to
Check Service State for MyService (write result into variable ISSERVICERUNNING)
MessageBox: $TITLE$, service: $ISSERVICERUNNING$
if Variable ISSERVICERUNNING Equals RUNNING
  MessageBox: $TITLE$, in if block
end



It doesn't actually have the $ signs around the ISSERVICERUNNING in the if block.

It does not work.

Posted: Mon Jul 23, 2007 5:37 am
by MichaelNesmith
I created a simple script like this:

Code: Select all

Check Service State for Themes (write result into variable TEST_SERVICE)
MessageBox: Testing Service, $TEST_SERVICE$
if Variable TEST_SERVICE Equals RUNNING
  MessageBox: Test service..., is running!
end


Which works exactly as expected.