ZTree.com  | ZEN  | About...  

 Index   Back

[Q] how do i test if a string is a number?   [Q]

By: David Wall       
Date: Aug 23,2017 at 19:54
In Response to: [Q] how do i test if a string is a number? (Ryan)

> how do i test if a string is a number?
>
>
> SET /A NN=123 is not a problem
>
> but
>
> Set /A NN=abc returns %NN% as 0
>
> then we can not tell the difference from Set /A NN=0 which also returns
> %NN% as 0

Set /a sets the variable to the equivalent number - there is no equivalent number to abc thus it gets set to 0.

If you just did set NN=0 or set NN=abc then you would get the correct result when then tested.

just try it without the /a option.

Either that or use Google to read up on it like I did.

398 views      
Thread locked
 

Messages in this Thread

 
95,077 Postings in 11,987 Threads, 350 registered users, 36 users online (0 registered, 36 guests)
Index | Admin contact |   Forum Time: Aug 14, 2020 - 6:17 pm EDT  |  Hits:33,120,672  (20,434 Today )
RSS Feed