Home > ASP Development > globalize arrays in function

globalize arrays in function



Here is the code that I use in a lot of applications:


Code:



cmd.CommandText="SELECT ID, Brand FROM Brands ORDER BY Brand;"
set rs=cmd.execute
If not rs.EOF Then
ArrBrands=rs.GetRows
set rs=nothing
objBR=UBound(ArrBrands,2)
End If
cmd.CommandText="SELECT NTLogon, LastName + ', ' + FirstName FROM Associates WHERE QADE='1' AND Active='1';"
set rs=cmd.execute
If not rs.EOF Then
ArrQNTID=rs.GetRows
set rs=nothing
objQR=UBound(ArrQNTID,2)
End If
cmd.CommandText="SELECT NTLogon, LastName + ', ' + FirstName FROM Associates WHERE DataEntry='1' AND Active='1';"
set rs=cmd.execute
If not rs.EOF Then
ArrONTID=rs.GetRows
set rs=nothing
objOR=UBound(ArrONTID,2)
End If






I would like to create a QC_Load_Arrays like so:






Code:



Function QC_Load_Arrays ()
cmd.CommandText="SELECT ID, Brand FROM Brands ORDER BY Brand;"
set rs=cmd.execute
If not rs.EOF Then
ArrBrands=rs.GetRows
set rs=nothing
objBR=UBound(ArrBrands,2)
End If
cmd.CommandText="SELECT NTLogon, LastName + ', ' + FirstName FROM Associates WHERE QADE='1' AND Active='1';"
set rs=cmd.execute
If not rs.EOF Then
ArrQNTID=rs.GetRows
set rs=nothing
objQR=UBound(ArrQNTID,2)
End If
cmd.CommandText="SELECT NTLogon, LastName + ', ' + FirstName FROM Associates WHERE DataEntry='1' AND Active='1';"
set rs=cmd.execute
If not rs.EOF Then
ArrONTID=rs.GetRows
set rs=nothing
objOR=UBound(ArrONTID,2)
End If
End Function

QC_Load_Arrays ()

...
For iCtr=0 to objBR
%><option value="<%=ArrBrands(0,iCtr)
%>"><%=ArrBrands(1,iCtr)
%></option>
Next
..








How can I get around to this?

    
Guest


What's problem are you facing



No need to do like this




Code:


<%For iCtr=0 to objBR%>
<option value="<%=ArrBrands(0,iCtr)%>"><%=ArrBrands(1,iCtr)
%></option>
Next






Do like this


Code:


<%For iCtr=0 to objBR%>
<option value=<%=ArrBrands(0,iCtr)%>><%=ArrBrands(1,iCtr)
%></option>
Next



Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by master_key
What's problem are you facing




So I can just do this (with functions in main.inc):

<!-- #include file="functions/main.inc" -->

If objFLAG=1 Then

QC_Load_Arrays()

...

<build html codes here with option tags>

...

ElseIf objFLAG=2 Then

....

End If

Was this answer helpful ? Yes No   
Guest


The simple way is to add

dim arrName ' note no brackets

to your main script, thus declaring them as global

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved