I was writing a script today and wanted to check if a variable was empty or not. So I used a text formula to see if the variable was empty ("").
This appears to work fine, until that is the variable just contained a dash ( - ). Even though BD detected the dash was there (i.e. it was visible in a Show Message dialogue), as far as the check was concerned, it considered the variable to be empty.
Was wondering if anyone else was able to replicate this?
Yes can reproduce this result with a dash as well as full stop and comma (may be other symbols but not tested). Appears BD considers these as equal to blank but will correctly identify if compared to actual value, ie variable with dash compared to constant containing a dash will return true.
Not sure if this is a problem but handy to know if a script does not operate as expected. Once aware likely we can work around it.
Hmm .. well this came about as I was using a RegExp to specifically look for certain special characters such as dash, comma and full stop. I then need to check the result variable to see if any was found - if blank then nothing found. If BD decides that a string containing , . or - is blank then this is not at all helpful!
I can think of potential workarounds, such as adding a normal character to the end of the return string, then trimming the first character from the string, then testing for the added character. I assume DB will consider a dash dot or comma as a character eligible to be trimmed!!?? I will need to test. But really these sort of workarounds shouldn't be necessary.