473,395 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using a function instead of a variable

Windows Server 2003, IIS 6, ASP Classic

I need to do something like this:

dim pageNum
pageNum = request("page")
if pageNum = "" then pageNum = 1

....and I need to do it several times. Another approach would be to do
this:

function fnPageNum
fnPageNum = request("page")
if fnPageNum = "" then fnPageNum = 1
end function

dim pageNum
pageNum = fnPageNum

In one method more efficient than the other, or do IIS not care either
way?

Bill in Kansas City

Jan 17 '06 #1
3 1201
se******@hotmail.com wrote:
Windows Server 2003, IIS 6, ASP Classic

I need to do something like this:

dim pageNum
pageNum = request("page")
if pageNum = "" then pageNum = 1

...and I need to do it several times. Another approach would be to do
this:

function fnPageNum
fnPageNum = request("page")
if fnPageNum = "" then fnPageNum = 1
end function

dim pageNum
pageNum = fnPageNum

In one method more efficient than the other, or do IIS not care either
way?

IIS does not care. For pure maintainability, I would use the function. The
criterion is: never write the same sequence of code more than once. If it
needs to be done more thaan once, encapsulate it in a sub or a function.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jan 17 '06 #2
Use a generic function like this:-

dim pageNum

pageNum = GetRequestValue("page", 1)

Function GetRequestValue(Name, Default)
GetRequestValue = Request(Name)
If GetRequestValue = Empty Then
GetRequestValue = Default
End If
End Function
"se******@hotmail.com" wrote:
Windows Server 2003, IIS 6, ASP Classic

I need to do something like this:

dim pageNum
pageNum = request("page")
if pageNum = "" then pageNum = 1

....and I need to do it several times. Another approach would be to do
this:

function fnPageNum
fnPageNum = request("page")
if fnPageNum = "" then fnPageNum = 1
end function

dim pageNum
pageNum = fnPageNum

In one method more efficient than the other, or do IIS not care either
way?

Bill in Kansas City

Jan 17 '06 #3
That's sort of where I was to begin with, but I figured I'd ask.
Ultimately, while I was waiting for the reply, that's what I did
anyway. I have a rather large project, and it made sense.

Thanks for taking the time!

- Bill

Jan 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
1
by: Epson Barnett | last post by:
Hi, I'm new to C# and I'd like to be able to reference a field of an object using a variable instead of literal text. In the PHP scripting language, you can create a variable: $var = "name";...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
5
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right...
5
by: Ghislain Tanguay | last post by:
Hi! I'm maybe from old school but, for me, whebn it's time to call a method from DCOM, remoting or web service returning a string or anything else I use a function. It's more verbose. In my new...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
4
by: Immortal_Nephi | last post by:
I had a lot of research to see how function pointer works. Sometimes, programmers choose switch keyword and function in each case block can be called. Sometimes, they choose ordinary function...
3
by: TamaThps | last post by:
I have to write a program that lets the user play the game of Craps. As of right now it is incomplete and I have run into some errors. It's my first time using functions instead of the program all...
0
by: Luis Zarrabeitia | last post by:
Quoting Joe Strout <joe@strout.net>: I'm sure your credentials are bigger than mine. But he is right. A lot of languages have ditched the "concept" of a static variable on a method (how do you...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.