Jump to content

Setting variable to empty string make it a 0 value


This topic is 2289 days old. Please don't post here. Open a new topic instead.

Recommended Posts

can you post the actual script?  Setting a variable to "" should kill the variable and it will not even show up in the data viewer.  Do you still see your variable in the data viewer set to 0?

(if you do: make sure you don't have anything else like a "watch" in the data viewer or a script trigger that sets it to 0 explicitly)

Link to comment
Share on other sites

I am using an eval copy of FM Pro so no data viewer until I actually buy the advanced version (which I am probably doing this week.)

I refactored my script so I no longer need to set the variable to empty (it was a stupid thing to do anyway). I tried to create another script to reproduce the behavior, but it is working as expected now - no 0's in sight.

This is a simplified version of what I was doing - I can't copy/paste the script into plain text to post here:

Set Variable [$StudentIDs; Value: ""]
Show Custom Dialog ["StudentIDs is:" & $StudentIDs]

The dialog was saying:  StudentIDs is:0

In earlier code I was placing a comma delimited list from the results from an ExecuteSQL into the variable and iterating through the list, "popping" each element with Left/Position and Middle/Position calculations until empty and then existing loop. 

- Brad

Link to comment
Share on other sites

1 hour ago, Brad Mathews said:

This is a simplified version of what I was doing - I can't copy/paste the script into plain text to post here:

Set Variable [$StudentIDs; Value: ""]
Show Custom Dialog ["StudentIDs is:" & $StudentIDs]

The dialog was saying:  StudentIDs is:0

Well, that's obviously too "simplified" - since it would not produce the claimed result.

I am guessing you were either using a different variable, or looking at the result of a numerical operation involving that variable - e.g. 3 * $undefinedVariable will return 0.

Link to comment
Share on other sites

"When I set a variable this way: Set Variable [$StudentIDs = ""] the actual value of $StudentIDs is 0, not empty or blank. So it fails the IsEmpty test."

You cannot declare a variable that way. Setting a variable requires at least two entries; the variable name; and the value.

If you HAVE put a value into $studentIDs; and later TEST for $studentIDs=""; then the correct result is in fact 0; because the statement is false.

That's why it would have been helpful to see your complete and exact script.

Link to comment
Share on other sites

Bruce,

I think we have a winner!

I did try and go back to duplicate that incorrect syntax when attempting to recreate the problem, but it would not let me - it insisted on using the gear icon which of course forces correct syntax. So I assumed I had just typed it wrong into the forum post so did not mention it.

I still can't figure out how I managed that incorrect syntax.

- Brad

Link to comment
Share on other sites

This topic is 2289 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.