not(1)

1. Member
Join Date
Dec 1969
Posts
81

## not(1)

In classic asp, why is not(1) equal to -2???<BR><BR>Should it not(1) be zero?

2. Senior Member
Join Date
Dec 1969
Posts
5,104

## Not sure what you mean...

Show some code to better explain your problem.<BR><BR>-Doug

3. Member
Join Date
Dec 1969
Posts
81

## RE: Not sure what you mean...

response.write(not(1))

4. Senior Member
Join Date
Dec 1969
Posts
5,104

## Why would you do that?

Are you trying to flip a boolean value?<BR><BR>Response.Write Not True<BR>Response.Write Not False<BR><BR>Why not just use true/false values?<BR><BR>-Doug

5. Member
Join Date
Dec 1969
Posts
81

## RE: Why would you do that?

Im testing the length of a string, whose source is a html form element, to see if the client has left it blank or not.<BR><BR>I did this<BR><BR>if not(len(sExample)) then sExample="Default value"<BR><BR>but it doesnt work because not(1) turns out to be -2 for some reason in asp... which then tests as being true (i.e. non-zero) and causes the variable to contain the default value!

6. Senior Member
Join Date
Dec 1969
Posts
5,104

## Len returns a number not a boolean value...

Do this:<BR><BR>if len(sExample) = 0 then sExample="Default value"

7. Member
Join Date
Dec 1969
Posts
81

## RE: Len returns a number not a boolean value...

You&#039;re right - but running any non-zero number through a not gate should produce zero.

8. Senior Member
Join Date
Dec 1969
Posts
5,104

## Wouldn't you have to do?

NOT(CBln(1)) -- to actually verify that your working with a boolean?<BR><BR>-Doug

9. Member
Join Date
Dec 1969
Posts
81

## RE: Wouldn't you have to do?

Possibly, Im not sure.<BR><BR>Try doing not(1) in any real programming language (such as c++)and you will see what I mean. Not 1 is always zero... but not so in asp!

#### Posting Permissions

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