Raised This Month: $51 Target: $400
 12% 

Get "or ||" in #elseif defined something "or" something.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-10-2009 , 09:10   Get "or ||" in #elseif defined something "or" something.
Reply With Quote #1

So how to get "||" in #if defined?
Example:
PHP Code:
#if defined XX || XX2 
Or maybe this?
PHP Code:
#if defined XX | XX2 
Which of this is true?

Last edited by xbatista; 04-10-2009 at 10:02.
xbatista is offline
Send a message via Skype™ to xbatista
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:15   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #2

In a C book I found:

#if defined VAR1 && defined VAR2

I would assume you could use "logical OR" also.

Just test it. If you get an error or incorrect result then it doesn't work.
__________________
fysiks is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-10-2009 , 09:25   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #3

Error: extra characters online.
PHP Code:
#define XX
//#define XX2
#else if defined XX || defined XX2 
Maybe "else" bad?
xbatista is offline
Send a message via Skype™ to xbatista
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:38   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #4

Why do you have and else in there?

look at my post again.
__________________
fysiks is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-10-2009 , 09:41   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #5

I've just have a problem with "else" and I need "||"
PHP Code:
#if defined XX3
do_something(id)
#else if defined XX || defined XX2
do2_something(id)
#endif 
xbatista is offline
Send a message via Skype™ to xbatista
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-10-2009 , 09:45   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #6

Use elseif not else if
__________________
Bugsy is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-10-2009 , 09:48   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #7

Quote:
Use elseif not else if
Omg thx
And,
What i must use? "||" or this "|" ?
xbatista is offline
Send a message via Skype™ to xbatista
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-10-2009 , 09:48   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #8

| = bit-wise OR
|| = conditional OR

Use ||
__________________
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 09:49   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #9

use "||" (it's the logical operator) "|" is a bitwise operator I believe.
__________________
fysiks is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-10-2009 , 09:50   Re: Get "or ||" in #if defined something "or" something.
Reply With Quote #10

WoW,thx for explaining. ;)
EDIT:
Something again wrong in this line:
#elseif defined XX || defined XX2

Last edited by xbatista; 04-10-2009 at 09:52.
xbatista is offline
Send a message via Skype™ to xbatista
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode