Ask Variable with If has anyone used something like this??

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Esabik
Pro Scripter
Posts: 52
Joined: Wed Jun 15, 2005 8:03 pm
Location: Fairfield, NJ

Ask Variable with If has anyone used something like this??

Post by Esabik » Tue Jan 07, 2014 10:09 pm

I have an application I need to use this for and I can't get this to work. I havent found anything similar in my searches in the forums. Can anyone help me with what I am missing?? :?:

ask>Did you sent the clock on the PC back to the previous year?,Yes
//If answer if yes then user input name
if>vYes={"YES"}
goto>Entername
label>EnterName
Input>name,Please enter your name:
//If answer is no then ask if done
else if>vYes={"NO"}
ask>Are you sure your done??,Done
endif
label>End :roll:
Just when you thought it was safe to go in the water........:evil:

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Wed Jan 08, 2014 2:15 am

The issue was with your first line. The v was missing.
ask>Did you sent the clock on the PC back to the previous year?,vYes

Code: Select all

ask>Did you sent the clock on the PC back to the previous year?,vYes
//If answer if yes then user input name
if>vYes={"YES"}
goto>EnterName
label>EnterName
Input>name,Please enter your name:
//If answer is no then ask if done
else if>vYes={"NO"}
ask>Are you sure your done??,Done
endif
label>End
I have also cleaned up your script a little, please have a look, up to you if you want to use it.

Code: Select all

Ask>Did you set the clock on the PC back to the previous year?,vClockQuestion

If>vClockQuestion={"YES"}
  Goto>EnterName
EndIF

If>vClockQuestion={"NO"}
  Goto>AreYouDone
EndIF


Label>EnterName
Let>INPUT_BROWSE=0
Input>name,Please enter your name:

Label>AreYouDone
ask>Are you sure your done??,vDoneQuestion

If>vDoneQuestion={"YES"}
  Goto>End
EndIf

Label>End
FIREFIGHTER

User avatar
Esabik
Pro Scripter
Posts: 52
Joined: Wed Jun 15, 2005 8:03 pm
Location: Fairfield, NJ

Post by Esabik » Wed Jan 08, 2014 2:19 pm

[quote="CyberCitizen"]The issue was with your first line. The v was missing.
ask>Did you sent the clock on the PC back to the previous year?,vYes


Thanks for the help on this. I appreciate you cleaning up the logic as well. I also see why this was confusing for me. I got the idea for this from the help file in macro. It doesn't list that "v" in the info. This is what the help reads:

*** Ask>prompt,result_variable
Displays a Yes, No dialog box with the specified prompt. If the user presses 'Yes', result_variable is set to 'YES', else result_variable becomes 'NO'.

The result is returned in upper case.
prompt can be a variable containing the prompt to display.

It is possible to set a timeout by setting the value of ASK_TIMEOUT before issuing the Ask command. ASK_TIMEOUT takes a number of milliseconds. If the Ask box is still active after the timeout has elapsed it will be closed and the result set to YES.

See also: Input, Message, MessageModal

Example

Ask>Do you want to continue ?,continue ***


So since I didn't see it here, I didn't know it was required. It was sure puzzling though lol....... :oops:
Just when you thought it was safe to go in the water........:evil:

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Jan 08, 2014 7:13 pm

Hi Esabik,
Esabik wrote:
CyberCitizen wrote:The issue was with your first line. The v was missing.
ask>Did you sent the clock on the PC back to the previous year?,vYes


Thanks for the help on this. I appreciate you cleaning up the logic as well. I also see why this was confusing for me. I got the idea for this from the help file in macro. It doesn't list that "v" in the info. This is what the help reads:

*** Ask>prompt,result_variable
Displays a Yes, No dialog box with the specified prompt. If the user presses 'Yes', result_variable is set to 'YES', else result_variable becomes 'NO'.

The result is returned in upper case.
prompt can be a variable containing the prompt to display.

It is possible to set a timeout by setting the value of ASK_TIMEOUT before issuing the Ask command. ASK_TIMEOUT takes a number of milliseconds. If the Ask box is still active after the timeout has elapsed it will be closed and the result set to YES.

See also: Input, Message, MessageModal

Example

Ask>Do you want to continue ?,continue ***


So since I didn't see it here, I didn't know it was required. It was sure puzzling though lol....... :oops:
Just so you know, there is nothing magical about the letter v there.

In your Ask> line, you used vYes as your result variable... so you have to refer to that variable in later lines of code by its name which is vYes.

You could have used result_variable as the name of your result variable... like in the Help File example... and then in later lines of code, of course you would have to refer to that variable by its name which would be result_variable.

Macro Scheduler does not much care how you name your variables... but once you create and populate a variable, you MUST refer to it by its name.

With variable names like vSomething... I'd say the user may have chosen to start it with a v as a reminder that this is a variable. You could use VarSomething for the same effect but again, the Var part would be for the person's benefit... to know this was a variable.

My only advice would be:

1) don't be afraid of long DESCRIPTIVE variable names. I would have used...

user_indicated_they_set_pc_clock_back_to_previous_year

...because later in the code you can write:

If>user_indicated_they_set_pc_clock_back_to_previous_year=YES
...code
Else
...code
EndIf

2) Avoid single character variable names like the PLAGUE... they can get you into trouble and create some unexpected results.

Take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts