Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Setting variable to empty string make it a 0 value

Featured Replies

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.

Is this by design, it is a bug or am I doing something stupid?

- Brad

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)

  • Author

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

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.

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

  • Author

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

Perhaps you did:

Set Variable [ $StudentIDs; Value:$StudentIDs = "" ] 

That would set the variable to 0, provided it wasn't empty beforehand.

 

  • Author

Ah yes, that looks likely. I am used to actual programming languages with real IDEs and such, so that looks like something I might have done out of habit.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.