ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old May 22nd, 2003, 03:58 PM
ejrhodes ejrhodes is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 24 ejrhodes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Should be 2 simple questions, variables and random

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?

PHP Code:
<%    
    Function 
ShuffleinArrayneeded )
        
' 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 Intincnt 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 (effectivelyshrink 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 
    
    %> 

Reply With Quote
  #2  
Old May 22nd, 2003, 04:25 PM
ejrhodes ejrhodes is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 24 ejrhodes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Bingo, i forgot the randomize function. Can you figure out why someties it displays blank values? the output is www.13datacenter.com/test.asp

As for question 1, i am looking for an asp equivalent to
HEREDOC so that I can assign a table to a variable. and then print that variable.

Last edited by ejrhodes : May 22nd, 2003 at 04:30 PM.

Reply With Quote
  #3  
Old May 22nd, 2003, 04:49 PM
ejrhodes ejrhodes is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 24 ejrhodes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Got it working
PHP Code:
<%
    
Randomize        
    
Function ShuffleinArrayneeded )
        
' find out how many input elements there are...
        incnt = UBound( inArray ) -1  ' 
I added the minus 1
        
' 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 
1 To needed
            
' choose a random number from 1 to our current input array usage size...
            choose = Int( incnt * Rnd(1) ) + 1
            response.write choose
            ' 
put that chosen element into the next slot in the output array...
            
outArray) = inArraychoose )
            
            
' here's the tricky partSince we just used the "choose" elementwe don't need
            ' 
it any more...we replace it with the last element of the in-use part of the array!
            
inArraychoose ) = inArrayincnt )
            
            
' and then we (effectively) shrink the array!
            ' 
Next time through the loopthere will be
            
' one fewer elements in the array to choose
            ' 
from...because we have (effectivelydeleted
            
' 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 Shufflepooladdress)
    
correctaddress="TEST"
    
    
randomize
    sh
(IntRnd(1) ) + 1)= cstr(correctaddress)
    
response.write "<SELECT NAME='serviceprovider'>"
    
For 1 to 5
        Response
.Write "<option value='" sh(i) & "'>" sh(i) & "</option>"
    
Next 
    response
.write "</select>"
    
%> 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Should be 2 simple questions, variables and random


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM Developerworks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway