WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IsNumber Problem


Question:

I'm using Winbatch 2004E and trying to pull data from HTML. I use TidyCom and turn an HTML table into XML and then pull data from it.

Part of the routine double-checks to make sure the user inputs all numerics. So I change it into XML and loop thru 125 INPUTs in a few seconds. However when it checks a certain value using IsNumber() it thinks that it's a number when it's a string.

************************************************************

*** Debug Initialized ***

==============================
Wed 1/12/2005 8:49:10 PM
WinBatch 32 2004E
WIL DLL 5.3eec
C:\Program Files\RPC\Program\RPC Template Maker.wbt
Windows platform: NT, version: 5.1, build: 2600
==============================

[snip to the chase]

to PX_Cells.length-1
(50) FOR TRUE==>2

PX_val = PX_Cells.item(PX_c).getAttribute("value")
(60) VALUE=> 1D4 ;<------------ ***

if isNumber(PX_val)
(60) IF DO==>TRUE

PX_Cells.item(PX_c).setAttribute("class", "bigblue silver")
(60) VALUE=> 

else
(70) END OPERATOR

PX_ThisRow = iteminsert(PX_val, -1, PX_ThisRow, ",")
(70) VALUE=> "2,0,1D4"

next
(70) END OPERATOR
I double-checked the MSXML SDK help and it says that the .getAttribute returns a Variant, so I tried using ObjectType to turn it into a string, but that didn't work either.

Answer:

1D4 is a number.

Its 1.0 * 10**4 or 10000, double precision.

The IsNumber is really more like

CanThisPossiblyBeConvertedToAValidNumber()

1D4 10000
1.23D4 12300
1d4 10000
6.67d4 64700
1.2d-4 0.000124

1E4
1.23E4
2.34e4
2.456e299
etc. D d E e are treated the same, although technically D is Exponent of a double-precision floating point number (native Winbatch format) and E is a Exponent of a single-precision floating point number.

All considered numbers, as WinBatch accepts numbers in "scientific notation".

The "D" or "E" qualifiers specify how far many places the decimal pint should be moved to the left or right.

This is different from but similar to a problem where someone had big long random lists of character strings. like

cic86ds 23 kc930t, 00465k ks99s 20044 23 kfjs8 00023 sds s 1d4 dfdf 10000

and he wanted to know if any of the strings were exactly the same or not...There were issues.

23 was the same as 00023 and 1d4 was the same as 10000

When WinBatch noticed that both of the things it was comparing could be numbers...it gleefully compared the numbers instead of strings. Thus unexpected strings were considered equal.

These handy negatively-typed languages can jump out and bite you on the ankles sometimes.

Solution...check for and reject strings containing letters. And are decimal points OK.?


Article ID:   W16975
File Created: 2007:07:03:14:27:26
Last Updated: 2007:07:03:14:27:26