| Handle Variables ASP Tutorial - ASP Web Pro |
|
ASP TutorialsNEW WAY TO HANDLE VARIABLESThe 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. 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.
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?
I hope by now you can see the potential of what all of the
above means to you as the developer..... 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 Thanks for your contribution Rob!
|
||||||
|
Main Menu Other Resources
Last Updated:
|
||||||
|
© 1997-2010 ASP Web Pro, Inc. | Terms of Use
|