[ASP/VBscript] Strange handling of Or comparisons

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default [ASP/VBscript] Strange handling of Or comparisons

    Suppose I have the following test in ASP/VBscript:

    If (IsEmpty(l_sAppVar) Or l_sAppVar = "" Or DateDiff("d", CDate(l_sAppVar), Date()) > 0) Then
    ...
    End If

    then ASP complains about a type mismatch for CDate(l_sAppVar) when l_sAppVar is indeed "".

    This seems strange to me, because when the first or second evaluation in the test returns True, then it is not necessary anymore to evaluate the other components of the test.
    Am I missing something?

    --
    Marja Ribbers-de Vroed

    Company website:
    [url]www.webwaresystems.nl[/url]
    Dreamweaver extensions:
    [url]www.flevooware.nl/dreamweaver/[/url]


    Marja Ribbers Guest

  2. Similar Questions and Discussions

    1. Strange 404 error handling on Apache web server
      My group recently pulled out of hosting, and now we're on a Solaris server running Apache 1.3.29 (A bit behind the times, but I've got no control...
    2. comparisons and depth
      sorry to post two questions in one day, but i have run into a second problem. i have a looping movie clip which changes _y position randomly with...
    3. #26080 [NEW]: Comparisons always true in xml.c
      From: AxelLuttgens at swing dot be Operating system: Darwin 7.0.0 (Panther) PHP version: 4.3.3 PHP Bug Type: Compile Warning...
    4. chaining comparisons
      When I learned python I was overjoyed that I could evaluate 1 < 2 < 3 and get "true". I just realized that you can't do that in Ruby. Is there a...
    5. Date comparisons
      Hi. I'm using ADO.NET to retrieve data from SQL Server via stored procedures. Lately I found the following problem: There's a stored procedure...
  3. #2

    Default Re: [ASP/VBscript] Strange handling of Or comparisons

    Marja,

    In many languages and compilers, evaluation of a condition
    - either starts with the last term
    - or does all evaluations regardless of result

    So I guess you'll have to check first in a separate if the l_sAppVar is
    empty or not.

    regards
    Bernard


    Marja Ribbers wrote:
    > Suppose I have the following test in ASP/VBscript:
    >
    > If (IsEmpty(l_sAppVar) Or l_sAppVar = "" Or DateDiff("d", CDate(l_sAppVar), Date()) > 0) Then
    > ...
    > End If
    >
    > then ASP complains about a type mismatch for CDate(l_sAppVar) when l_sAppVar is indeed "".
    >
    > This seems strange to me, because when the first or second evaluation in the test returns True, then it is not necessary anymore to evaluate the other components of the test.
    > Am I missing something?
    >
    bthouin Guest

  4. #3

    Default Re: [ASP/VBscript] Strange handling of Or comparisons

    You'd need to nest the statements. eg

    if boo then
    if foo then

    end if
    end if

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004



    Julian Roberts Guest

  5. #4

    Default Re: [ASP/VBscript] Strange handling of Or comparisons

    I know how to work around this, but it just seemed strange to me that an Or comparison would be processed this way.

    --
    Marja Ribbers-de Vroed

    Company website:
    [url]www.webwaresystems.nl[/url]
    Dreamweaver extensions:
    [url]www.flevooware.nl/dreamweaver/[/url]


    "Julian Roberts" <newsg@charon.co.uk> wrote in message news:d1sea7$b5e$1@forums.macromedia.com...
    > You'd need to nest the statements. eg
    >
    > if boo then
    > if foo then
    >
    > end if
    > end if
    >
    > --
    > Jules
    > [url]http://www.charon.co.uk/charoncart[/url]
    > Charon Cart 3
    > Shopping Cart Extension for Dreamweaver MX/MX 2004
    >
    >
    >
    Marja Ribbers Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139