Undefined Variable Handling?

Results 1 to 5 of 5

Thread: Undefined Variable Handling?

  1. #1
    Fraser Murrell Guest

    Default Undefined Variable Handling?

    Hi,<BR><BR>Using JSCRIPT in ASP, I`m trying to detect if a variable is as yet undefined.<BR><BR>If I try :<BR><BR>var Mode;<BR><BR>if(Mode == undefined)<BR> Response.Write("Mode Undefined!");<BR><BR> .. I get a message back saying &#039undefined&#039 is undefined.<BR><BR>Is there a proper way of doing this?<BR><BR>Regards,<BR>Fraser

  2. #2
    Big Al Guest

    Default RE: Undefined Variable Handling?

    With in your ASP write at the top <BR>&#060;%Option Explicit %&#062; This must be the first line in your page. But means that all varavbles must be called before they are used. hope this is what you wanted..

  3. #3
    Fraser Murrell Guest

    Default RE: Undefined Variable Handling?

    Hi Al,<BR><BR>Not quite what I was after. I`m using JScript, which should return "undefined" when referecing an undeclared variable anyway, so I think the option explicit thing is VBScript only. My problem was actually getting this undefined value back.. found the following code actually returns it though :<BR><BR>if(typeof(Mode) == "undefined")<BR> Response.Write("Mode Undefined!");<BR><BR>Thanks for the reply anyway,<BR>Fraser

  4. #4
    Join Date
    Dec 1969

    Default RE: Darned Cross-posting!!!!

    I&#039ve just spent ten minutes answering this in the JScript forum.<BR><BR>CROSS-POSTING IS EVIL!!!!!<BR><BR>Dunc

  5. #5
    Fraser Murrell Guest

    Default RE: Darned Cross-posting!!!!

    Sorry Dunc.. I`m new to this board, and originally wrote it in the ASP conference before noticing there was actually a JSCRIPT specific conf!! <BR><BR>It wont happen again.. honest!<BR><BR>Cheers again<BR>Fraser

Posting Permissions

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