



(1 ratings)
The EASIEST way to deal with variables!!
Allow me to introduce myself.
My name is Rob Collyer, I lay eyes upon ASP years ago and
have been heavily coding since.
It always struck me as a complete pain in the neck the way
in which we have all been dealing with variables in ASP, for
as long as we have used ASP.
What do I mean? ........ Allow me to explain with this example of the hard way:-
|
Rather than go on longer than necessary into yet more lines looking exactly the same as the ones above, to put my point across, I'll put you out of your misery.
Why do variables have to be this TEDIOUS to deal with??? I wanted a way to read in all variables at once in one go, with just one function call.... I must be mad.... sure enough, I was told this as well as things like 'It's not possible', etc.
Sure enough, at the time, it wasn't possible. To my rescue came Microsoft, with Version 5 of the VBScript engine and a new command called Execute. Execute(string) basically executes a string as though it were ASP.. So Execute("Response.write ""Hello"") .... would have the same effect as just using response.write "hello"
As soon as I saw this new feature I knew instantly what I could do with it:-
|
We are setting variables automatically. That one little tiny
piece of code, has saved me so much time over the last year,
you will not believe.
Ok, it does have it flaws, Forms with image submit buttons
pass form variable names like "submit.X", and "submit.Y"
(Co-ordinates where you clicked on the submit image) which
obviously wont do for variable names in ASP, and results in
the white error page from hell.... But we can start to prevent
these things:-
|
Why stop there?? There are many silly characters that are fine in HTML controls as names, but when setting variable names automatically like this in VBScript, these characters will not do. You can easily add additional lines as above to escape other characters like spaces, hyphens and all manner of other ones too.
You've got multiple controls on forms.... how are you gonna
assign variables to multiple select boxes?
As a developer, I found it handy to read these 'multiple'
part form variables into an array... I will build upon the
above code to handle multiple items and create arrays from
them:-
|
I hope by now you can see the potential of what all of the
above means to you as the developer.....
I urge you all to write your own functions that'll handle
variables the way you want them to, and please remember....
FORMS were just an example, don't stop there, after all there
are Querystrings, Cookies, Session variables, Application
Variables, ServerVariables. Then there are recordsets (why
not?) and the dictionary objects, etc, etc, etc.
Just remember, you are now armed with info which will save you a great deal of time, why not get busy writing some variable handling functions of your own??
If anybody wants a function to selectively handle Form, Querystring, Cookies, Session, Application and Server variables then I have one...just mail me. It also has a parameter to run in DEBUG mode which will show you variables in all objects, their values and whether their names present a problem during conversion. It'll also flag those controls that can be set to arrays, etc.
Anyway, those that do feel inspired to get writing their own handlers, let me ask one thing.... Send me a copy of your finished function(s), this is pretty new stuff and I'm well open to being inspired by YOUR code.
Feel free to contact me with your feedback.
Enjoy!
Rob Collyer
ASPwiz@hotmail.com
20 Random Tutorials from the same category :
DISPLAY DATA FROM DATABASE
AIM Profile Screenname Viewer as a component of AIM Profile Designs
ASP.NET in Dreamweaver 8
The Connection Object
GLOBAL.ASA IN ASP
SQL Access Methods In ASP
Server Variables In ASP
Date and Time Functions In ASP
Installing ASP on your own computer
ASP.NET 2 Special Purpose Folders
String Functions
Displaying Server Values In ASP
Processing Form Information In ASP
Passing Query Strings In Asp
Counting Visitors In ASP
Iterating through Collections In ASP
ASP Components
FORMAT SPECIAL DATA
Reading a Database
Counter in ASP














