Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resetting all variables to null and undeclaring variables

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
Hi,

I have a search script (generated by a third party product) that sits in various folders of my intranet along with some index files. I have modified this script so it only shows the number of results without the actual results.

I then have a main search screen which is meant to show the number of hits in each of the various indexes. I then use 'include' to list them one after the other

<br>
<!--#include virtual="../opm/search/searchcount.asp"-->
<br>
<!--#include virtual="../knowledge/search/searchcount.asp"-->
<br>

This works fine for the first one but when it tries to run the script in the knowledge folder it comes across lines where variables are redefined. I tried removing all of these lines but there is still stuff in memory being carried over from the one in the OPM folder so the number of results shown is the same.

Is there a way of resetting everything in one move so the script can run from scratch each time or will I have to go through the code to find out what is being carried across from the first execution?
 
move the declaration of the variables into a seperate include and declare it just the once.

or

recode the script into a function that doesn't need to be in the folder and simply call it with a parameter

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
I agree with Chris, declaring your variables locally in the function is a better practice.

Howeverm to answer your original question, you can assign the value of Empty to your variables and this will basically reset them. Empty is a keyword for a variables value that has never been assigned a value. Basically this is what a value is set to when it is declared and it holds that value until you change it.
A handy function at this point is the IsEmpty function, to check if the value is empty.

 
Not only is what Chris and Tarwn stated about global variables correct it is the way it is and should be done period. Global variables are viewed upon as extremely bad form and unstructured along with messy. This goes bad to programming 101. Don't use them as they only cause problems

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top