[Javascript] Re: While statement array losing data
Nick Fitzsimons
nick at nickfitz.co.uk
Thu May 17 08:26:12 CDT 2007
On 17 May 2007, at 14:15:22, Tim Lewis wrote:
> I finally found my problem. Apparently if an array item is
> populated with
> a numeric value, the value gets lost after leaving the While loop. A
> string is preserved. I changed the code to change the integer to a
> string:
> sLineIn[iResultCount] = sTransCount+"";
> It works now.
>
Your reply overlapped with my reply to your original question :-)
However, the stuff in my previous reply is still relevant. What
happens when you do the above is that JScript will try to add the
empty string to whatever is referenced by sTransCount, find that the
referenced thing is a COM object, and convert it to a JScript string
by taking its default (in this case "Value") property (as I described
previously). So it's the same thing as using the default property of
the Field object, as VBScript does by default.
If you're working with COM objects such as ADO RecordSets and
associated objects, it's worth understanding the difference between
them and JScript objects - the difference doesn't arise in VBScript,
as that is also "built out of COM", but JScript (which is at heart a
COM component) adds some of its own behaviours, and removes or masks
others.
There's an article mentioning one of the differences at Eric
Lippert's blog - he's the guy who wrote VBscript and was involved in
writing JScript:
<http://blogs.msdn.com/ericlippert/archive/2003/09/15/53005.aspx>
with links to more information.
Regards,
Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/
More information about the Javascript
mailing list