Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 asp question
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Freeman II
Junior Member

232 Posts

Posted - 21 July 2001 :  03:02:14  Show Profile
whats the difference between function and sub?

gor
Retired Admin

Netherlands
5511 Posts

Posted - 21 July 2001 :  03:53:26  Show Profile  Visit gor's Homepage
A function returns a value while a sub doesn't

So you could have something like:

blnOk = CheckMyValue(inValue)

where you would use a sub like this:

WriteRecord recordId

or

Call WriteRecord(recordId)

This doesn't mean you can't set values of other variables in a sub though.

When to use a sub or a function ?
That depends on what you want.
Maybe the WriteRecord sub in my example didn't write out to the screen, but to a file and you wanted to be able to easely retrieve a returnvalue that indicates success or failure of the write.
Then you probably would use a function so you could do something like this:

blnSuccess = WriteRecord(recordId)

The code inside the sub/function could be exactly the same except that in the function you would have a line that says something like:

WriteRecord = ...... to set the returnvalue of the function.


Pierre
Join the Snitz WebRing
Go to Top of Page

Freeman II
Junior Member

232 Posts

Posted - 21 July 2001 :  11:01:41  Show Profile
thanks gor!

im trying to replace this code for active user with a function or sub so the webmaster doesn't have to add new lines when they add new pages. (which one do you think will work better?)
---inc_top.asp--------
If lcase(Right(strOnlinePathInfo, 9)) = "forum.asp" Then
strOnlineLocation = "<a href=""forum.asp?" & strOnlineQueryString & """>" & Request.QueryString("Forum_Title") & "</a>"
----------------------
add something like this at the top of each page

curPageName = Forums
curPageDes = "<a href=""forum.asp?" & strOnlineQueryString & """>" & Request.QueryString("Forum_Title") & "</a>"


then add a function or sub to retrieve this info.

Go to Top of Page

Freeman II
Junior Member

232 Posts

Posted - 22 July 2001 :  12:01:12  Show Profile
any ideas? this might be useful to other mods too

Go to Top of Page

gor
Retired Admin

Netherlands
5511 Posts

Posted - 22 July 2001 :  16:07:52  Show Profile  Visit gor's Homepage
I don't really understand what you are asking in that previous reply....


Pierre
Join the Snitz WebRing
Go to Top of Page

Freeman II
Junior Member

232 Posts

Posted - 22 July 2001 :  16:53:57  Show Profile
what i was trying to say is instead of using these line to detect the page name
---inc_top.asp--------
If lcase(Right(strOnlinePathInfo, 9)) = "forum.asp" Then
strOnlineLocation = "<a href=""forum.asp?" & strOnlineQueryString & """>" & Request.QueryString("Forum_Title") & "</a>"
----------------------
why can't we add the info on every page then add something into inc_top.asp to retrive this info so you don't have to add lines like this "If lcase(Right(strOnlinePathInfo, 9)) = "forum.asp" Then" into inc_top.asp each time you make a new page. don't you think that it will speed up the forum? cuz you don't have to compile all those lines, just the current page

Go to Top of Page

gor
Retired Admin

Netherlands
5511 Posts

Posted - 22 July 2001 :  17:18:24  Show Profile  Visit gor's Homepage
Oh...ehm...really have never looked at the Active Users Mods...so don't know if there is a faster/easier way to do that...maybe one of the others knows ?

Pierre
Join the Snitz WebRing
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.75 seconds. Powered By: Snitz Forums 2000 Version 3.4.07