|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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, |
|
#2
|
|||
|
|||
|
yes, they will only run when you call them.
|
|
#3
|
||||
|
||||
|
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, |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
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:
|
|
#6
|
|||
|
|||
|
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) |
|
#7
|
||||
|
||||
|
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, |
|
#8
|
|||
|
|||
|
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?
|
|
#9
|
||||
|
||||
|
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, |
|
#10
|
|||
|
|||
|
aspnewbie told you already. look above...
|
|
#11
|
||||
|
||||
|
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, |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > ASP Function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|