ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 15th, 2002, 08:30 AM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 7
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
ASP Function

Hi!

I have a page dedicated to ASP Functions that I need to run at various places throughout my asp site. Is there a way that I could only have certian functions run inside of that page? For example; they only run when I call them?

Thank You,
__________________
Andrew J Durstewitz
ASP.NET,VB.NET,SQL Developer

http://madashellnc.blogspot.com

Reply With Quote
  #2  
Old October 15th, 2002, 10:58 AM
bbolte bbolte is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 11 bbolte User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yes, they will only run when you call them.

Reply With Quote
  #3  
Old October 15th, 2002, 11:03 AM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 7
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
How?

How exactly do you call them?

For example;

Function do_this_now
Dim somthing
Dim something else
Blah = blah + blah
End Function

As for as I have been working with it I can still use blah eventhough I haven't called for the Function to run?

I think I am missing something.

Thanks,

Reply With Quote
  #4  
Old October 15th, 2002, 12:11 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
There are a couple of ways. You can call them by by saying "Call NameoftheFunction" in your asp code or you can just say "theNameoftheFunction". When using "call", the arguments are placed within the paratheses. If you don't use call, then the arguments can be listed without parentheses.

For example:

Code:

Do while not rs.EOF

  MessageID = rs("MessageID")
  Call ShowMessage(x,y,z)  'here's where you call the function
  rs.Movenext

Loop

etc etc




or

Code:

Do while not rs.EOF

  MessageID = rs("MessageID")
  ShowMessage x,y,z
  rs.Movenext

Loop


At the end of your code (or in your include file) you would have the function ShowMessage

Code:

Function ShowMessage(x,y,z)

details of function

End Function


Use functions if you need to return a value and subs if you don't

Hope this helps!

Last edited by aspnewbie : October 15th, 2002 at 07:58 PM.

Reply With Quote
  #5  
Old October 15th, 2002, 12:28 PM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 7
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
Related Question

So Functions souldn't run by themself then right? What is happening in that I have one page (func.asp) which containes all of my Functions for the website.

I am using and include statement to bring the Functions only into the pages where I require them.

BUT! For some reason my variable is still... The variable should only be set if the function is run? So why then isn't the variable just blank?

I will attach code.

PLEASE DISREGUARD ANY WORD WRAP.

Quote:
<%
' Function AlphaNumericBase28(digits) ----------------------------------------------------------------

Dim RSInfo
Dim RSInfo_numRows

Set RSInfo = Server.CreateObject("ADODB.Recordset")
RSInfo.ActiveConnection = MM_spotnote_STRING
RSInfo.Source = "SELECT CUSTOMER_ID FROM CUSTOMER_INFORMATION"
RSInfo.CursorType = 0
RSInfo.CursorLocation = 2
RSInfo.LockType = 1
RSInfo.Open()

RSInfo_numRows = 0

Function AlphaNumericBase28(digits)

Dim char_array(35)

char_array(0) = "0"
char_array(1) = "1"
char_array(2) = "2"
char_array(3) = "3"
char_array(4) = "4"
char_array(5) = "5"
char_array(6) = "6"
char_array(7) = "7"
char_array(8) = "8"
char_array(9) = "9"
char_array(10) = "B"
char_array(11) = "C"
char_array(12) = "D"
char_array(13) = "F"
char_array(14) = "G"
char_array(15) = "J"
char_array(16) = "K"
char_array(17) = "L"
char_array(18) = "M"
char_array(19) = "N"
char_array(20) = "P"
char_array(21) = "Q"
char_array(22) = "R"
char_array(23) = "S"
char_array(24) = "T"
char_array(25) = "V"
char_array(26) = "W"
char_array(27) = "X"
char_array(28) = "Z"

Randomize

'Loop through and create the output based on the the variable passed to the function for the length of the key.
Do While len(output) < 4
num = char_array(Int((28 - 0 + 1) * Rnd + 0))
output = output + num
Loop

'Set return
AlphaNumericBase28 = output

'Close the function
End Function

' Set the final variable for the AlphaNumeraric Function
show = AlphaNumericBase28(4)

' If the database is empty then don't do this
If NOT RSInfo.EOF Then
db_custid = (RSInfo.Fields.Item("CUSTOMER_ID").Value)
End If

' Check database to insure this isn't allready in it
Do While NOT RSInfo.EOF
If show = db_custid Then
' item allready in database
show = AlphaNumericBase28(4)
Else
RSInfo.MoveNext
End If
Loop

' Close the database
RSInfo.Close()
Set RSInfo = Nothing

' END Function AlphaNumericBase28(digits) ----------------------------------------------------------------

Reply With Quote
  #6  
Old October 15th, 2002, 12:55 PM
bbolte bbolte is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 11 bbolte User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the first thing i see is this:

' Function AlphaNumericBase28(digits) ----------------------------------------------------------------

you've commented the function name out so everything will run right out of the box.

take the comment out:

Function AlphaNumericBase28(digits)

Reply With Quote
  #7  
Old October 15th, 2002, 01:03 PM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 7
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
look down...

Bill,

Thanks for your reply but look down 12 lines to after the database connection. That is where the function actually starts.

I have the beginning commented so I know what function I am currently working with.

Thanks,

Reply With Quote
  #8  
Old October 15th, 2002, 02:08 PM
bbolte bbolte is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 11 bbolte User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
oops missed it. ok, if i understand the function, you pass a variable in called "digits". yet you don't use this anywhere. you have another variable called "output" that isn't dimmed or set to anything, so it's zero or null maybe. should you change output for digits to actually use the number you're passing in?

Reply With Quote
  #9  
Old October 15th, 2002, 02:18 PM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 7
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
Ooops.

Bill,

I have removed the the (digits) part. That was a typo on my part. Do you know of anyway that I can call the script instead of it just running?

Thanx,

Reply With Quote
  #10  
Old October 15th, 2002, 06:02 PM
bbolte bbolte is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 11 bbolte User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
aspnewbie told you already. look above...

Reply With Quote
  #11  
Old October 16th, 2002, 08:23 AM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 7
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
Finally Understand

Thank you to all of you who replied to this post. Finally I understand how functions work. For some reason I was under the impression that a fuction would not process unless you called it. Turns out they process (if in a page that is being processed) like everything else, if you need to use the functions results use the function name and it will give it to you.

Thank you again everyone,

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > ASP Function


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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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