Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Application object and arrays


Message #1 by "Selenia" <Grandmaster@t...> on Thu, 27 Sep 2001 13:32:49 +0200

Hi !

I also wrote this a couple of days to "beginning_asp" m but no one answered

so far , so I am trying my luck here now.

My global.asa looks like the following :



.....

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart

dim feld (19)

for i=0 to 19

feld(i)=" "

next



Application("eng")=feld



End Sub



So Application("feld") is an array , right?!



Well , in an asp page I try the follwing :

<%@ LANGUAGE = VBScript %>

<%  Option Explicit %>

<% dim feld , x %>

<%

feld=application("eng")

Response.Write(UBound(feld , 1))

%>



But it doesnīt work. I get two errors :

if I make dime feld() instead of dim feld , I get a "data type mismatch

error" and with dim feld I get the error "type mismatch".

UBound is an official VBScript function that gives you the upper dimension

of an array .

So Response.Write(UBound(feld, 1 )) should give me the size of  feld aka

Application("eng") .

Can you please explain me why it is not working?  Do you maybe know another

way to get the size of the "array" Application("eng") .

Is there a way to create dynamically Application objects? So I donīt put

them in the global.asa under the Application_On_Start event but create them

out of a  normal asp script?



Thanks for your time!



Selenia







Message #2 by "phil griffiths" <pgtips@m...> on Thu, 27 Sep 2001 14:54:27
Well there must be something else, either in your global.asa or your asp 

page because this works fine.  I pasted it into a clean global.asa and a 

new asp page and I got '19' back in the browser.



Post your complete code and we'll have a look.



If you use Dim feld() you are getting a type mismatch because your array 

is not initialized. You can get away with just Dim feld because feld is a 

variant datatype and variants can contain arrays, so no problem.



As to your other question, you can set Application variables from anywhere 

- it doesn't have to be in global.asa.  Just remember to use 

Application.Lock before the change and .Unlock after.



HTH

Phil

> 

> Hi !

> I also wrote this a couple of days to "beginning_asp" m but no one 

answered

> so far , so I am trying my luck here now.

> My global.asa looks like the following :

> 

> .....

> <SCRIPT LANGUAGE=VBScript RUNAT=Server>

> Sub Application_OnStart

> dim feld (19)

> for i=0 to 19

> feld(i)=" "

> next

> 

> Application("eng")=feld

> 

> End Sub

> 

> So Application("feld") is an array , right?!

> 

> Well , in an asp page I try the follwing :

> <%@ LANGUAGE = VBScript %>

> <%  Option Explicit %>

> <% dim feld , x %>

> <%

> feld=application("eng")

> Response.Write(UBound(feld , 1))

> %>

> 

> But it doesnīt work. I get two errors :

> if I make dime feld() instead of dim feld , I get a "data type mismatch

> error" and with dim feld I get the error "type mismatch".

> UBound is an official VBScript function that gives you the upper dimension

> of an array .

> So Response.Write(UBound(feld, 1 )) should give me the size of  feld aka

> Application("eng") .

> Can you please explain me why it is not working?  Do you maybe know another

> way to get the size of the "array" Application("eng") .

> Is there a way to create dynamically Application objects? So I donīt put

> them in the global.asa under the Application_On_Start event but create them

> out of a  normal asp script?

> 

> Thanks for your time!

> 

> Selenia
Message #3 by "Selenia" <Grandmaster@t...> on Thu, 27 Sep 2001 17:47:11 +0200
Hello Phil!



Thank you for answering me and helping to find the solution :) . It seems it

is no coding problem but a server problem , not initalizing the global.asa

correct.

I used to have my skripts in a subfolder of the root and then moved them to

the root and voila it worked :) . Then moved them back to the subfolder and

it didnīt work. Then I waited some minutes tried it again and it worked ,

looks like for me the asp service or something has problems.



Selenia



"phil griffiths" <pgtips@m...> schrieb im Newsbeitrag

news:105638@a..._web_howto...

>

> Well there must be something else, either in your global.asa or your asp

> page because this works fine.  I pasted it into a clean global.asa and a

> new asp page and I got '19' back in the browser.

>

> Post your complete code and we'll have a look.

>

> If you use Dim feld() you are getting a type mismatch because your array

> is not initialized. You can get away with just Dim feld because feld is a

> variant datatype and variants can contain arrays, so no problem.

>

> As to your other question, you can set Application variables from anywhere

> - it doesn't have to be in global.asa.  Just remember to use

> Application.Lock before the change and .Unlock after.

>

> HTH

> Phil
Message #4 by "phil griffiths" <pgtips@m...> on Fri, 28 Sep 2001 09:42:00
Glad you found the solution.  This is not a problem with your server - 

global.asa must be in the root direrctory.  You can't put it anywhere else.



Phil

> Hello Phil!

> 

> Thank you for answering me and helping to find the solution :) . It 

seems it

> is no coding problem but a server problem , not initalizing the 

global.asa

> correct.

> I used to have my skripts in a subfolder of the root and then moved them 

to

> the root and voila it worked :) . Then moved them back to the subfolder 

and

> it didnīt work. Then I waited some minutes tried it again and it worked ,

> looks like for me the asp service or something has problems.

> 

> Selenia

> 

> "phil griffiths" <pgtips@m...> schrieb im Newsbeitrag

> news:105638@a..._web_howto...

> >

> > Well there must be something else, either in your global.asa or your 

asp

> > page because this works fine.  I pasted it into a clean global.asa and 

a

> > new asp page and I got '19' back in the browser.

> >

> > Post your complete code and we'll have a look.

> >

> > If you use Dim feld() you are getting a type mismatch because your 

array

> > is not initialized. You can get away with just Dim feld because feld 

is a

> > variant datatype and variants can contain arrays, so no problem.

> >

> > As to your other question, you can set Application variables from 

anywhere

> > - it doesn't have to be in global.asa.  Just remember to use

> > Application.Lock before the change and .Unlock after.

> >

> > HTH

> > Phil
Message #5 by "Selenia" <Grandmaster@t...> on Fri, 28 Sep 2001 15:33:08 +0200
The global.asa was and is in the root directory , but still I can acess

Application and Session objects in a script lying a subfolder , right?



Selenia





"phil griffiths" <pgtips@m...> schrieb im Newsbeitrag

news:105877@a..._web_howto...

>

> Glad you found the solution.  This is not a problem with your server -

> global.asa must be in the root direrctory.  You can't put it anywhere

else.

>

> Phil

> > Hello Phil!

> >

> > Thank you for answering me and helping to find the solution :) . It

> seems it

> > is no coding problem but a server problem , not initalizing the

> global.asa

> > correct.

> > I used to have my skripts in a subfolder of the root and then moved them

> to

> > the root and voila it worked :) . Then moved them back to the subfolder

> and

> > it didnīt work. Then I waited some minutes tried it again and it worked

,

> > looks like for me the asp service or something has problems.

> >

> > Selenia

> >

> > "phil griffiths" <pgtips@m...> schrieb im Newsbeitrag

> > news:105638@a..._web_howto...

> > >

> > > Well there must be something else, either in your global.asa or your

> asp

> > > page because this works fine.  I pasted it into a clean global.asa and

> a

> > > new asp page and I got '19' back in the browser.

> > >

> > > Post your complete code and we'll have a look.

> > >

> > > If you use Dim feld() you are getting a type mismatch because your

> array

> > > is not initialized. You can get away with just Dim feld because feld

> is a

> > > variant datatype and variants can contain arrays, so no problem.

> > >

> > > As to your other question, you can set Application variables from

> anywhere

> > > - it doesn't have to be in global.asa.  Just remember to use

> > > Application.Lock before the change and .Unlock after.

> > >

> > > HTH

> > > Phil

>

>





Message #6 by "phil griffiths" <pgtips@m...> on Fri, 28 Sep 2001 15:05:13
Yes scripts in subfolder can access Application and Session objects.



> ...still I can acess

> Application and Session objects in a script lying a subfolder , right?

> 

> Selenia


  Return to Index