Wow, been using VBScript forever. Just recently started using Javascript more
and more (I used to do a lot of Javascript, but switched because we weren't
allowed to where I work...now we can).

So, now that I have the knowledge of the scripting objects, I tried implementing
the Scripting.Dictionary object in JavaScript (passing it back and forth to
VBScript contained in an IE window). Ya know, you have to go through a few hoops
to get the Dictionary to function properly in Javascript.

IE:

var dict = new ActiveXObject('Scripting.Dictionary');

dict.Add('Key1', 'Value1');
dict.Add('Key2', 'Value2');
dict.Add('Key3', 'Value3');

var keys = new VBArray(dict.Keys()).toArray();
var vals = new VBArray(dict.Values()).toArray();

// To iterate through the arrays using an index...
for (var i = 0; i < keys.length; i++) {
// Just storing the value into a buffer.
buf += '\n' + keys[i] + ' = ' + vals[i];
}

Kinda nuts eh? Darn SafeArrays.

Mythran

Re: JavaScript - VBScript - VBArray by Stan

Stan
Tue Jul 20 10:57:43 CDT 2004

I'm not sure that I would ever use a Dictionary object in JavaScript. Isn't
it just as easy to do this:

<script language="javascript">
var dict = new Array();
dict['Key1'] = val1;
dict['Key2'] = val2;
dict['Key3'] = val3;
}
</script>

and then retrieve the array values by name?

Stan Scott
New York City

"Mythran" <kip_potter@hotmail.com> wrote in message
news:uGl5J6mbEHA.1248@TK2MSFTNGP11.phx.gbl...
> Wow, been using VBScript forever. Just recently started using Javascript
more
> and more (I used to do a lot of Javascript, but switched because we
weren't
> allowed to where I work...now we can).
>
> So, now that I have the knowledge of the scripting objects, I tried
implementing
> the Scripting.Dictionary object in JavaScript (passing it back and forth
to
> VBScript contained in an IE window). Ya know, you have to go through a
few hoops
> to get the Dictionary to function properly in Javascript.
>
> IE:
>
> var dict = new ActiveXObject('Scripting.Dictionary');
>
> dict.Add('Key1', 'Value1');
> dict.Add('Key2', 'Value2');
> dict.Add('Key3', 'Value3');
>
> var keys = new VBArray(dict.Keys()).toArray();
> var vals = new VBArray(dict.Values()).toArray();
>
> // To iterate through the arrays using an index...
> for (var i = 0; i < keys.length; i++) {
> // Just storing the value into a buffer.
> buf += '\n' + keys[i] + ' = ' + vals[i];
> }
>
> Kinda nuts eh? Darn SafeArrays.
>
> Mythran
>
>



Re: JavaScript - VBScript - VBArray by Christoph

Christoph
Tue Jul 20 15:12:39 CDT 2004

20.07.2004 17:30, Mythran schrieb:

> Wow, been using VBScript forever. Just recently started using Javascript more
> and more (I used to do a lot of Javascript, but switched because we weren't
> allowed to where I work...now we can).
>
> So, now that I have the knowledge of the scripting objects, I tried implementing
> the Scripting.Dictionary object in JavaScript (passing it back and forth to
> VBScript contained in an IE window). Ya know, you have to go through a few hoops
> to get the Dictionary to function properly in Javascript.

Since JavaScript-Objects are enumerable and associative without additional
means you will very rarely need an ActiveX-Dictionary:

var dict = new Object();

dict.Key1 = 'Value1';
dict.Key2 = 'Value2';
dict.Key3 = 'Value3';

var buf ='';

for (key in dict) {
buf += '\n' + key + ' = ' + dict[key];
}

alert (buf);


--
Gruesse, Christoph

Re: JavaScript - VBScript - VBArray by Mythran

Mythran
Tue Jul 20 18:52:56 CDT 2004

Creating the Dictionary in VBScript then passing back and forth to JavaScript
(required for this situation because the reference will be invalid if I created
it in the JavaScript window first).

Mythran

"Christoph Basedau" <e_tonne@hotmail.com> wrote in message
news:40fd7e96$0$5923$9b4e6d93@newsread4.arcor-online.net...
> 20.07.2004 17:30, Mythran schrieb:
>
> > Wow, been using VBScript forever. Just recently started using Javascript
more
> > and more (I used to do a lot of Javascript, but switched because we weren't
> > allowed to where I work...now we can).
> >
> > So, now that I have the knowledge of the scripting objects, I tried
implementing
> > the Scripting.Dictionary object in JavaScript (passing it back and forth to
> > VBScript contained in an IE window). Ya know, you have to go through a few
hoops
> > to get the Dictionary to function properly in Javascript.
>
> Since JavaScript-Objects are enumerable and associative without additional
> means you will very rarely need an ActiveX-Dictionary:
>
> var dict = new Object();
>
> dict.Key1 = 'Value1';
> dict.Key2 = 'Value2';
> dict.Key3 = 'Value3';
>
> var buf ='';
>
> for (key in dict) {
> buf += '\n' + key + ' = ' + dict[key];
> }
>
> alert (buf);
>
>
> --
> Gruesse, Christoph



Re: JavaScript - VBScript - VBArray by Daniel

Daniel
Wed Jul 21 09:01:50 CDT 2004

Hello:

since you may have the solution to my problem i would like to ask you
something, is there any problem to use

<SCRIPT LANGUAGE="VBScript"> and <SCRIPT LANGUAGE="javascript"> in the smae
page?

i am having a trouble and i suspect that maybe is this.

in a page where i use both i try the following script and it gives me an
error saying Object doesn't support this property or method when i try to
call MiFuncion

<SCRIPT LANGUAGE="VBScript">

<!--

Sub MiFuncion()

Dim Inicio

DIM Dias

Inicio = #07/01/2004#

form1.startdate.value = Inicio

dias = int(form1.horas.value) / int("8")

form1.final.value = inicio + int(dias)

End Sub

-->

</SCRIPT>

i call it like this:

<input name="final" type="Text" id="final" onFocus="Mifuncion">

When i try this in a page with only this script, it works fine

when i add it to the page where it goes, where there is other javascripts
also, it tells me that error.

Thanks for your help.

Daniel

"Christoph Basedau" <e_tonne@hotmail.com> wrote in message
news:40fd7e96$0$5923$9b4e6d93@newsread4.arcor-online.net...
20.07.2004 17:30, Mythran schrieb:

> Wow, been using VBScript forever. Just recently started using Javascript
more
> and more (I used to do a lot of Javascript, but switched because we
weren't
> allowed to where I work...now we can).
>
> So, now that I have the knowledge of the scripting objects, I tried
implementing
> the Scripting.Dictionary object in JavaScript (passing it back and forth
to
> VBScript contained in an IE window). Ya know, you have to go through a
few hoops
> to get the Dictionary to function properly in Javascript.

Since JavaScript-Objects are enumerable and associative without additional
means you will very rarely need an ActiveX-Dictionary:

var dict = new Object();

dict.Key1 = 'Value1';
dict.Key2 = 'Value2';
dict.Key3 = 'Value3';

var buf ='';

for (key in dict) {
buf += '\n' + key + ' = ' + dict[key];
}

alert (buf);


--
Gruesse, Christoph



Re: JavaScript - VBScript - VBArray by Mythran

Mythran
Wed Jul 21 09:54:55 CDT 2004

<input name="final" type="Text" id="final" onFocus="VBScript:Mifuncion">

Try that...

Mythran


"Daniel" <trabajosdemonster@hotmail.com> wrote in message
news:u$syHtybEHA.3012@tk2msftngp13.phx.gbl...
> Hello:
>
> since you may have the solution to my problem i would like to ask you
> something, is there any problem to use
>
> <SCRIPT LANGUAGE="VBScript"> and <SCRIPT LANGUAGE="javascript"> in the smae
> page?
>
> i am having a trouble and i suspect that maybe is this.
>
> in a page where i use both i try the following script and it gives me an
> error saying Object doesn't support this property or method when i try to
> call MiFuncion
>
> <SCRIPT LANGUAGE="VBScript">
>
> <!--
>
> Sub MiFuncion()
>
> Dim Inicio
>
> DIM Dias
>
> Inicio = #07/01/2004#
>
> form1.startdate.value = Inicio
>
> dias = int(form1.horas.value) / int("8")
>
> form1.final.value = inicio + int(dias)
>
> End Sub
>
> -->
>
> </SCRIPT>
>
> i call it like this:
>
> <input name="final" type="Text" id="final" onFocus="Mifuncion">
>
> When i try this in a page with only this script, it works fine
>
> when i add it to the page where it goes, where there is other javascripts
> also, it tells me that error.
>
> Thanks for your help.
>
> Daniel
>
> "Christoph Basedau" <e_tonne@hotmail.com> wrote in message
> news:40fd7e96$0$5923$9b4e6d93@newsread4.arcor-online.net...
> 20.07.2004 17:30, Mythran schrieb:
>
> > Wow, been using VBScript forever. Just recently started using Javascript
> more
> > and more (I used to do a lot of Javascript, but switched because we
> weren't
> > allowed to where I work...now we can).
> >
> > So, now that I have the knowledge of the scripting objects, I tried
> implementing
> > the Scripting.Dictionary object in JavaScript (passing it back and forth
> to
> > VBScript contained in an IE window). Ya know, you have to go through a
> few hoops
> > to get the Dictionary to function properly in Javascript.
>
> Since JavaScript-Objects are enumerable and associative without additional
> means you will very rarely need an ActiveX-Dictionary:
>
> var dict = new Object();
>
> dict.Key1 = 'Value1';
> dict.Key2 = 'Value2';
> dict.Key3 = 'Value3';
>
> var buf ='';
>
> for (key in dict) {
> buf += '\n' + key + ' = ' + dict[key];
> }
>
> alert (buf);
>
>
> --
> Gruesse, Christoph
>
>



Re: JavaScript - VBScript - VBArray by Michael

Michael
Wed Jul 21 18:39:22 CDT 2004

Daniel wrote:
> Hello:
>
> since you may have the solution to my problem i would like to ask you
> something, is there any problem to use
>
> <SCRIPT LANGUAGE="VBScript"> and <SCRIPT LANGUAGE="javascript"> in
> the smae page?
>
> i am having a trouble and i suspect that maybe is this.
>
> in a page where i use both i try the following script and it gives me
> an error saying Object doesn't support this property or method when i
> try to call MiFuncion


When you mix client side script languages in IE, the language of the first
<script> element encountered (in source file order) establishes the default
language for any inline script defined via on<eventname> attributes of
elements.

You can diambiguate by using

onsomeeventname='javascript:foo();'
onsomeeventname='vbscript:call foo()'
onsomeeventname='vbscript:foo'

etc...

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Re: JavaScript - VBScript - VBArray by Christoph

Christoph
Wed Jul 21 19:12:03 CDT 2004

21.07.2004 16:01, Daniel schrieb:

> is there any problem to use
>
> <SCRIPT LANGUAGE="VBScript"> and <SCRIPT LANGUAGE="javascript"> in the smae
> page?

Generally, it is not a problem.

> i am having a trouble and i suspect that maybe is this.
>
> in a page where i use both i try the following script and it gives me an
> error saying Object doesn't support this property or method when i try to
> call MiFuncion
>
> <SCRIPT LANGUAGE="VBScript">
> Sub MiFuncion()

> End Sub
> </SCRIPT>
>
> i call it like this:
>
> <input name="final" type="Text" id="final" onFocus="Mifuncion">
>
> When i try this in a page with only this script, it works fine
>
> when i add it to the page where it goes, where there is other javascripts
> also, it tells me that error.

IE's primary and default scripting-language is JScript, afaik.
If you use more then one scripting language in a document, IE takes
the first <script>-section's language as the document's default
script language.
Especially "inline"-script-code, that is assigned to eventhandlers like
onclick, onfocus, onmouseover, must follow the syntax-rules of this
language.

So you have several alternatives to solve the prob:
Either make the VBScript-part the first <script>-section of the doc,
or, like Mythran said, use the "VBScript:"-modifier prior to "MiFuncion"
or simply add two brackets to the call: "MiFunction()". Then it's
syntactically okay for both languages.

Afaik according to w3c one should use a meta-tag:

<META http-equiv="Content-Script-Type" content="<script-langaue-name">

to define the default (and the only) language for intrinsic script-code.
But afaik IE ignores this tag and instead uses the first script-language
or an autodection modus, if the language/type-attributes are omitted.


--
Gruesse, Christoph

Re: JavaScript - VBScript - VBArray by Christoph

Christoph
Wed Jul 21 19:12:26 CDT 2004

21.07.2004 01:52, Mythran schrieb:

> "Christoph Basedau" <e_tonne@hotmail.com> wrote in message
>>
>> Since JavaScript-Objects are enumerable and associative without additional
>> means you will very rarely need an ActiveX-Dictionary

> Creating the Dictionary in VBScript then passing back and forth to JavaScript
> (required for this situation because the reference will be invalid if I created
> it in the JavaScript window first).

Then you could manage the for-eaching inside the VBScript, which has
far more straight forward means for dealing with collections
and/or safearrays
--
Gruesse, Christoph