Using Messagebox results in an if statement


ncusack

Recommended Posts

Im wondering if there is a way to use a system.messagebox yesno prompt result as a parameter in an if statement. What im trying to do is have the prompt posing a question pop up and after the question is answered write the result to a file. For example I've created the question result a variable by saying

// pose question

Answer = system.messagebox("question?","yesno")

// log answer

if (answer = "yes")

//write to file

if (answer = "no")

//write to file

Every time i run this in the sequence I get a parameter failure. Can the results of the prompt even be used in this way?

Link to comment
Share on other sites

Yes you can do that, but you have three issues with your script:

1) you never declare Answer

2) the string comparison is case sensitive, and message box returns "Yes" and "No", not "yes" / "no"

3) comparison in DAQFactory uses ==, not =. = is used for assignment

So, using your pseudocode, it'd be something like:

// pose question
private string Answer = system.messagebox("question?","yesno")
// log answer

if (answer == "Yes")
   //write to file
endif
if (answer == "No")
   //write to file
endif

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.