Click to See Complete Forum and Search --> : Should be 2 simple questions, variables and random


ejrhodes
05-22-2003, 05:01 PM
1) Does ASP have functionality to assign a large block of HTML to a variable? What I am doing is emailing large reports in the body of an email. I am trying to set it up so that all i have to do is assign the body of the email to a variable. I could assign each line of the table to a variale I suppose but is there a way of doing it in one large block? I know PHP has this function, does ASP?

2) I am using the ASPFAQS.COm Shuffle Function but the random numbers generated are the same each time I refresh the page. Is there something wrong with my functions?

<%
Function Shuffle( inArray, needed )
' find out how many input elements there are...
incnt = UBound( inArray )
' then create the output array to be the size requested via the "needed" argument
dim outArray
redim outArray( needed )
' now we will select the number of values specified as "needed"...
For i = 1 To needed
' choose a random number from 1 to our current input array usage size...
choose = Int( incnt * Rnd(1) ) + 1

' put that chosen element into the next slot in the output array...
outArray( i ) = inArray( choose )

' here's the tricky part: Since we just used the "choose" element, we don't need
' it any more...we replace it with the last element of the in-use part of the array!
inArray( choose ) = inArray( incnt )

' and then we (effectively) shrink the array!
' Next time through the loop, there will be
' one fewer elements in the array to choose
' from...because we have (effectively) deleted
' the one just chosen!
incnt = incnt - 1

Next
' return the shuffled output
Shuffle = outArray
End Function



Dim pooladdress (10)
pooladdress(0)="1314 3rd street"
pooladdress(1)="1314 4th street"
pooladdress(2)="1314 5th street"
pooladdress(3)="1314 6th street"
pooladdress(4)="1314 7th street"
pooladdress(5)="1314 8th street"
pooladdress(6)="1314 9th street"
pooladdress(7)="1314 10th street"
pooladdress(8)="1314 11th street"
pooladdress(9)="1314 12th street"

sh = Shuffle( pooladdress, 5 )

correctaddress="TEST"

response.write Int( 5 * Rnd(1) ) + 1

For i = 1 to 5
Response.Write "<LI>" & i & " " & sh(i) & vbNewLine
Next

%>

ejrhodes
05-22-2003, 05:27 PM
forgot the randomize function. Can you figure out why someties it displays blank values? the output is www.13datacenter.com/test.asp (http://www.13datacenter.com/test.asp)

As for question 1, i am looking for an asp equivalent to
HEREDOC (http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc) so that I can assign a table to a variable. and then print that variable.