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.

268 views      
Thread locked
 

Messages in this Thread

 
94,476 Postings in 11,922 Threads, 348 registered users, 8 users online (0 registered, 8 guests)
Index | Admin contact |   Forum Time: Oct 17, 2019 - 4:05 pm EDT  |  Hits:28,768,877  (3,306 Today )
RSS Feed