Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@isdigit behaviour changed

May
238
2
Seems that @isdigit[] behavior changed between v15 and v18.

"echo %@isdigit[]" will return "1" in v18 while it returned "0" in v15.

This broke a btm file for me that relies on the old behavior in quite a few places.
I guess the fix (for me) would be to check if the variable given to @isdigit[] for checking is empty or not in addition to checking the @isdigit result. Still the v15 way is more convenient.
 
Prefix a zero to the argument. Instead of %@isdigit[%xx], use %@isdigit[0%xx].
 
Dave you've got it exactly backwards - prepending a numeric zero to the string will give him a "1" if the string empty but he wants it to return "0" in that case.

A quick and relatively easy way to adapt to the new behavior is to use a function like this:

Function MyIsDigit=`%@If["%1" == "",0,%@IsDigit[%1]]`

Now all you have to do is to change all occurences of "%@IsDigit" to "%@MyIsDigit".
 
Last edited:
Dave you've got it exactly backwards - prepending a numeric zero to the string will give him a "1" if the string empty but he wants it to return "0" in that case.

A quick and relatively easy way to adapt to the new behavior is to use a function like this:

Function MyIsDigit=`%@If["%1" == "",0,%@IsDigit[%1]]`

Now all you have to do is to change all occurences of "%@IsDigit" to "%@MyIsDigit".

Thanks, I already did something similar to account for the changed @isdigit behavior:

Code:
function isnumber=`%@if[%@len[%$] GT 0,%@isdigit[%$],0]`

I also want @isnumber[1 ] and @isnumber[1 0] and other similar values to return 0, so I have to use %$ instead of %1. There will only ever be one "real" argument to the function anyway.

Which takes care of this function, seems the other @is* functions were similarly changed, but I don't currently rely on them.

I haven't taken the step to upgrade my system to v18 yet, but it's good to be prepared when/if the time comes. I assume Windows 10 compability improvements will only make it to the latest version, so it might be necessary in due time.
 

Similar threads

Back
Top