Checking a variable has been declared

Results 1 to 4 of 4

Thread: Checking a variable has been declared

  1. #1
    J-P Guest

    Default Checking a variable has been declared

    How can I check that a variable has been declared? I know using Option<BR>Explicit will throw an error if a variable hasn&#039t been declared but this<BR>isn&#039t what I need. I&#039ve tried using isEmpty but that will only tell me if a<BR>variable has been declared and is empty. I need to check whether a variable<BR>has been declared and if it hasn&#039t, then declare it.<BR><BR>Many Thanks<BR>J-P<BR><BR>P.S. I have played around with Cold Fusion a little, this has a tag called CFPARAM, if anyone has come across it, this is the sort of functionality I am looking for.

  2. #2
    Jason Miller Guest

    Default RE: Checking a variable has been declared

    Okay, this might work...<BR><BR>on error resume next<BR>...<BR>eval("tempVar = " & varName)<BR>if err.number &#060;&#062; 0 then execute("dim " & varName)<BR>...<BR><BR>It is kind of getting into sticky territory with memory allocation and all, though...

  3. #3
    Join Date
    Dec 1969

    Default RE: Checking a variable has been declared

    I&#039d be curious to know why you would need to do this. Sounds like you are maybe including the same file twice, and inside of that file is a dim statement. I imagine there would be a better way around this, although realistically you should probably structure includes to prevent this from happening.<BR>

  4. #4
    J-P Guest

    Default RE: Checking a variable has been declared

    The reason is that I have created a file to disrtibute to our asp customers which enables them to pass payments on their website. They are required to include this file in the relevant page. The file has several required variables such as credit card number, expiry date etc. However, there are also a couple of optional variables that are not required but need to be at least declared on the page that is calling the include. The easy way out would be to state in the documentation that you have to at least declare all variables. I just thought it would be neater to let the include determine whether or not the optional variables were available.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts