Is there a windows scripting host function equivalent to visual
basic's VAR() funtion?

I'm comparing two large arrays containing data from separate files on
seperate computers. It seems that the internal program process
doesn't recognize the array elements appropriately. Particularly when
using operators such as greater or less than (>,<,=, etc...). example
would be something like this:

Array1(x,y) > Array2(z,m) And the Array1 element would always return
GREATER than no matter the size of the number (even if it is LESS
than) the Array2 element. This is fixed in visual basic when I apply
the VAR() to the arrays:

VAR(Array1(x,y)) > VAR(Array2(z,m))

That works! Hence my original question, since I need a script to do
said procedure..

Thanks in advance,
-V

Re: wsh equivalent to VAR() function by Joe

Joe
Thu Dec 04 16:44:13 CST 2003

Hi,

"Volumstein" <volumstein@yahoo.com> wrote in message
news:7dd12b91.0312041408.6eeee5d1@posting.google.com...
| Is there a windows scripting host function equivalent to visual
| basic's VAR() funtion?
|
| I'm comparing two large arrays containing data from separate files on
| seperate computers. It seems that the internal program process
| doesn't recognize the array elements appropriately. Particularly when
| using operators such as greater or less than (>,<,=, etc...). example
| would be something like this:
|
| Array1(x,y) > Array2(z,m) And the Array1 element would always return
| GREATER than no matter the size of the number (even if it is LESS
| than) the Array2 element. This is fixed in visual basic when I apply
| the VAR() to the arrays:
|
| VAR(Array1(x,y)) > VAR(Array2(z,m))
|
| That works! Hence my original question, since I need a script to do
| said procedure..
|
| Thanks in advance,
| -V

AFAIK there's no VAR equivalent. The problem you're experiencing, however,
may arise from the fact that VBS is an all variant language. It sounds like
you're comparing a variant string subtype to a variant numeric subtype.
When a string subtype is compared to a numeric subtype, the string subtype
is always greater. (This is documented in the CHM file, but not a matter
that most people catch until they experience it.) Try something like:

CLng(Array1(x,y)) > CLng(Array2(z,m))

or

CStr(Array1(x,y)) > CStr(Array2(z,m))

or simply coerce the numeric (if you're uncertain of type) with:

(Array1(x,y) +0) > (Array2(z,m) +0)

That will correct the problem, if it's a subtype mismatch.

Joe Earnest



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 09-23-03