Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > After Parenthesis in ASP Variables - Query

Reply
Thread Tools

After Parenthesis in ASP Variables - Query

 
 
ll
Guest
Posts: n/a
 
      05-27-2008
Hi,
I'm wondering about variable declaration in ASP - is there a good
resource for this? In naming variables, is there a way to include
characters in a variable name after the parenthesis/variable in a
loop? I have quite a few variables (e.g. strOut1_a, strOut2_a, etc)
and thought a loop would be the best way to do this, but I am getting
errors for the characters after the parenthesis. My code is below.
Thanks for any help or resources.
Louis

-----------------------------------------
for a=1 to 3
strOut(a)_a=objComm("Out"&a&"_a")
response.write("Out"&a&"_a")
next
 
Reply With Quote
 
 
 
 
Drew
Guest
Posts: n/a
 
      05-27-2008
Use an array,

dim a, arrStrOut(2) 'Remember arrays are zero based
for a = 0 to UBound(arrStrOut)
arrStrOut(a) = a
response.write(arrStrOut(a))
next

Drew

"ll" <> wrote in message
news:61aae1ea-6798-46fd-8deb-...
> Hi,
> I'm wondering about variable declaration in ASP - is there a good
> resource for this? In naming variables, is there a way to include
> characters in a variable name after the parenthesis/variable in a
> loop? I have quite a few variables (e.g. strOut1_a, strOut2_a, etc)
> and thought a loop would be the best way to do this, but I am getting
> errors for the characters after the parenthesis. My code is below.
> Thanks for any help or resources.
> Louis
>
> -----------------------------------------
> for a=1 to 3
> strOut(a)_a=objComm("Out"&a&"_a")
> response.write("Out"&a&"_a")
> next



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-27-2008
ll wrote:
> Hi,
> I'm wondering about variable declaration in ASP - is there a good
> resource for this?


I can see why you had trouble finding one, given that you were treating
ASP as a language rather than what it really is: a "platform" which
supports several scripting languages, including vbscript. I'm sure if
you knew you had to find a vbscript reference you would have found this
http://msdn.microsoft.com/en-us/libr...h6(VS.85).aspx
or this:
http://www.microsoft.com/downloads/d...DisplayLang=en

> In naming variables, is there a way to include
> characters in a variable name after the parenthesis/variable in a
> loop?


After the parentheses? No. I'm not sure there is a language where this
is allowed. Certainly not VB, VBA or vbscript. With vbscript, the
parentheses contain, when declaring the array, the maximum index value
to be stored in the array, and when referring to an item within the
array, the index of the item.

Have a look in the documentation about declaring and using arrays in
vbscript.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      05-27-2008
ll wrote:
> I'm wondering about variable declaration in ASP - is there a good
> resource for this? In naming variables, is there a way to include
> characters in a variable name after the parenthesis/variable in a
> loop? I have quite a few variables (e.g. strOut1_a, strOut2_a, etc)
> and thought a loop would be the best way to do this, but I am getting
> errors for the characters after the parenthesis. My code is below.
> Thanks for any help or resources.
> Louis
>
> -----------------------------------------
> for a=1 to 3
> strOut(a)_a=objComm("Out"&a&"_a")
> response.write("Out"&a&"_a")
> next


VBScript allows all kinds of funny variable names, provided you use
brackets. This is a valid expression:

[strOut(a)_a] = objComm("Out"&a&"_a")

It is not what you want, however, since it is merely a static variable name.


OTOH, you can probably get a little of what you want with JScript:

for (var ary=[],i=0; i<3; i++) {
ary.push({_abjComm("Out"&a&"_a")}
Response.Write(ary[i]._a)
}



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.


 
Reply With Quote
 
Old Pedant
Guest
Posts: n/a
 
      05-28-2008
First of all, there's no reason you couldn't put the suffix *BEFORE* the
parentheses:
-----------------------------------------
for a=1 to 3
strOut_a(a) = objComm("Out"&a&"_a")
next

But if you mean that you want *properties* on a SINGLE indexed variable of
an array...sure, you can do that. Using a VBScript class.

Silly (and not overly well formed) example, just to get the point across:

<%
Class Person
Private mName, mEmail

Public Sub Init( name, email )
me.mName = name
ne.mEmail = email
End Sub

Public Property Get Name( )
Name = me.mName
End Property
Public Property Get EMail( )
EMail = me.mEmail
End Property
End Class

Dim people( 10 )

Set people(3) = New Person
people(3).Init( "Adam", "")
Set people(7) = New Person
people(7).Init("Joe","")

....
x = 7

Response.Write people(x).Name & " has email address " & people(x).Email
....
%>

Is *THAT* what you are after?

 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-28-2008
Old Pedant wrote:
> First of all, there's no reason you couldn't put the suffix *BEFORE*
> the parentheses:
> -----------------------------------------
> for a=1 to 3
> strOut_a(a) = objComm("Out"&a&"_a")
> next
>
> But if you mean that you want *properties* on a SINGLE indexed
> variable of an array...sure, you can do that. Using a VBScript class.
>
> Silly (and not overly well formed) example, just to get the point
> across:
>


Now that was more helpful than my reply was. Thanks a lot for stepping in.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
ll
Guest
Posts: n/a
 
      05-29-2008
On May 28, 5:55 am, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
> Old Pedant wrote:
> > First of all, there's no reason you couldn't put the suffix *BEFORE*
> > the parentheses:
> > -----------------------------------------
> > for a=1 to 3
> > strOut_a(a) = objComm("Out"&a&"_a")
> > next

>
> > But if you mean that you want *properties* on a SINGLE indexed
> > variable of an array...sure, you can do that. Using a VBScript class.

>
> > Silly (and not overly well formed) example, just to get the point
> > across:

>
> Now that was more helpful than my reply was. Thanks a lot for stepping in.
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"




Thanks for all your help - this has helped immensely!

 
Reply With Quote
 
ll
Guest
Posts: n/a
 
      05-29-2008
On May 29, 11:05 am, ll <barn104_1...@yahoo.com> wrote:
> On May 28, 5:55 am, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
> wrote:
>
>
>
> > Old Pedant wrote:
> > > First of all, there's no reason you couldn't put the suffix *BEFORE*
> > > the parentheses:
> > > -----------------------------------------
> > > for a=1 to 3
> > > strOut_a(a) = objComm("Out"&a&"_a")
> > > next

>
> > > But if you mean that you want *properties* on a SINGLE indexed
> > > variable of an array...sure, you can do that. Using a VBScript class.

>
> > > Silly (and not overly well formed) example, just to get the point
> > > across:

>
> > Now that was more helpful than my reply was. Thanks a lot for stepping in.

>
> > --
> > Microsoft MVP - ASP/ASP.NET
> > Please reply to the newsgroup. This email account is my spam trap so I
> > don't check it very often. If you must reply off-line, then remove the
> > "NO SPAM"

>
> Thanks for all your help - this has helped immensely!



One more (hopefully quick) question... within the loops as shown in
my code, does each variable created (e.g. strOutP1, strOutP2, etc)
retain its value, or is an array needed for this?
Thanks again,
Louis
 
Reply With Quote
 
Old Pedant
Guest
Posts: n/a
 
      06-01-2008
> One more (hopefully quick) question... within the loops as shown in
> my code, does each variable created (e.g. strOutP1, strOutP2, etc)
> retain its value, or is an array needed for this?


Ummm...."loops"??? You only show ONE loop there.

And you don't show *ANY* variables name strOutP1 or strOutP2 or anything
similar to that.

What in the heck are you talking about??? Maybe code you didn't show us?


 
Reply With Quote
 
ll
Guest
Posts: n/a
 
      06-02-2008
On Jun 1, 12:40 am, Old Pedant <OldPed...@discussions.microsoft.com>
wrote:
> > One more (hopefully quick) question... within the loops as shown in
> > my code, does each variable created (e.g. strOutP1, strOutP2, etc)
> > retain its value, or is an array needed for this?

>
> Ummm...."loops"??? You only show ONE loop there.
>
> And you don't show *ANY* variables name strOutP1 or strOutP2 or anything
> similar to that.
>
> What in the heck are you talking about??? Maybe code you didn't show us?




Sorry for the confusion - allow me to just start from the beginning,
which might be easier. I have a set of variables
(strOut1_a....to...strOut15_a).
I'm looking for a way to loop through these variable names to
establish their values, such as:

strOut1_a = objComm("Out1_a")

but with a loop, rather than writing out each.
Many thanks again,
Louis
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
no parenthesis after window.onload=function_name nevil.4u@gmail.com Javascript 1 04-04-2007 04:54 AM
regular expression to insert spaces around parenthesis puzzlecracker Java 0 01-25-2006 07:31 PM
")" expected error when there's supppose to be only 1 set of parenthesis .Net Sports ASP .Net 4 06-29-2005 06:33 PM
bracket or parenthesis number in Documents Larry Smith Computer Support 3 02-15-2005 01:19 AM
Free IDE with Parenthesis Matching? Rogue Noir C++ 6 08-02-2003 06:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57