I observe the following issue when I read a long string from a CSV file. Sometimes this string is actually a long integer. If this integer is longer then 19 positions I get an error message when I perform an empty string check. Unfortunately the strings in the CSV file are not surrounded with quotes which would have solved this issue.
Let>test=12345678901234567890
// Error parsing expression:
If>{(%test%="")}
MessageModal>Empty string
EndIf
I tried several type conversions (like Concat, Format) however that did not solve this issue. My workaround is to check the length of this string. However, I think this is a bug which has to be solved.
Workaround:
Length>test,LT
If>{(%LT%=0)}
MessageModal>Empty string
EndIf
Max length integer 19 positions
Moderators: JRL, Dorian (MJT support)
Re: Max length integer 19 positions
Not really a bug. More a consequence of not needing to declare variables and their type. This topic has been discussed since the early days of Macro Scheduler time. Numbers are not supposed to be quoted in a complex expression. The long ago concluded solution is/was to append some text onto the number prior to testing. Something like this:
In this case, your solution for checking length and if the result is zero the string is empty is far more elegant. Good job!
You might also simply abandon the complex expression.
Code: Select all
Let>AppendedString=~!---!~UniqueNeverToBeEncounteredString~!---!~
Let>String=12345678901234567890
Let>test=%AppendedString%%String%
If>{%test%=%AppendedString%}
MessageModal>Empty string
EndIf
You might also simply abandon the complex expression.
Code: Select all
Let>test=12345678901234567890
If>test=
MessageModal>Empty string
EndIf
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Max length integer 19 positions
As JRL says this is nothing to do with the length it's to do with type. Your value is a number but your If comparison expects a string.
Another solution is to declare the variable as a string before assigning it. To do this just make sure the first time you declare the variable you assign a string to it:
So before reading the value from the file, declare it with Let and set it to a string:
Another solution is to declare the variable as a string before assigning it. To do this just make sure the first time you declare the variable you assign a string to it:
Code: Select all
//initialise variable to a string type
Let>test={""}
Let>test=12345678901234567890
// Error parsing expression:
If>{(%test%="")}
MessageModal>Empty string
EndIf
Code: Select all
Let>test={""}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?