Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20717

BASCOM-AVR : val function and _valcheck = 1 : NEWTOPIC

$
0
0
Hi, I'm using the val function and setting the const _valcheck to 1, which should cause the err variable to be set when the value being converted by val is not a numeric. This works well for almost all cases, except when the string being converted is blank. example [code:1:dc2247618c]const _valcheck = 1 dim stemp as string * 10 dim btemp as byte Stemp = "100" btemp=val(stemp) Print Stemp ; "=" ; Btemp ; "->" ; Err Stemp = "xxx" btemp=val(stemp) Print Stemp ; "=" ; Btemp ; "->" ; Err Stemp = "" btemp=val(stemp) Print Stemp ; "=" ; Btemp ; "->" ; Err End[/code:1:dc2247618c] It's not really a major problem, you just need to check if the numeric returned is not 0 (In my case the value should be >0 and < 1024), but if 0 is a valid value for you then you need to check that the string is not blank and that starts getting really messy. Regards Ian Dobson [b:dc2247618c][color=red:dc2247618c](BASCOM-AVR version : 2.0.7.6 )[/b:dc2247618c][/color:dc2247618c]

Viewing all articles
Browse latest Browse all 20717

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>