• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

is defined

Guest
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

Hi i need to do something like this but dont think its the right code, as i dont get the right result

do i have the or in the right place?

<CFIF NOT IsDefined("session.Username") or ("session.AdminUsername")>
<CFLOCATION URL="Login.cfm">
</CFIF>
TOPICS
Advanced techniques

Views

356

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

<CFIF NOT IsDefined("session.Username") or NOT IsDefined("session.AdminUsername")>
<CFLOCATION URL="Login.cfm">
</CFIF>

or

<CFIF NOT (IsDefined("session.Username") or IsDefined("session.AdminUsername"))>
<CFLOCATION URL="Login.cfm">
</CFIF>

depending on what you want.





Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

Actually shouldn't that be
NOT IsDefined("...") AND NOT IsDefined("...")

With an OR operand one of those two options will always be true and the
cflocation will alway be run. That isn't the desired effect is it?

BKBK wrote:
> <CFIF NOT IsDefined("session.Username") or NOT IsDefined("session.AdminUsername")>
> <CFLOCATION URL="Login.cfm">
> </CFIF>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

Actually shouldn't that be NOT IsDefined("...") AND NOT IsDefined("...")
Perhaps. I did add "depending on what you want", which leaves some leeway. The key suggestion to JohnGree was that the isDefined() function has to be repeated for every variable. Hence, isDefined("var_A") and/or isDefined("var_B"), rather than isDefined("var_A") and/or ("var_B").

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 29, 2006 Jun 29, 2006

Copy link to clipboard

Copied

LATEST
On Thu, 29 Jun 2006 08:48:52 -0700, Ian Skinner wrote:

> Actually shouldn't that be
> NOT IsDefined("...") AND NOT IsDefined("...")
>
> With an OR operand one of those two options will always be true and the
> cflocation will alway be run.

How do you figure that?

<cfset a = 1>
<cfset b = 2>
<cfif not isDefined("a") or not isDefined("b")>
Either expression was true
<cfelse>
Neither expression was true
</cfif>


I think you are getting confused with this sort of nonsense:
<cfif a is not 1 or a is not 2>
Will always be true: if it's 1, then it's not 2. If it's 2 then it's not
1.
</cfif>

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation