The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Software Design
|
if problem
Discuss if problem in the Software Design forum on Dev Shed. if problem Software design forum discussing design principles and non-language specific algorithms. Get help with logic, algebraic, or relational concepts.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 15th, 2002, 02:59 PM
|
|
Junior Member
|
|
Join Date: Jul 2002
Location: Pozarevac, Yugoslavia
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
if problem
i write this code:
if ((($first != "+") OR ($first != "-")) AND (($last != "+") OR ($last != "-"))) {
.....
}
but not work properly...why? and can i write it in some other (better) way
|

October 15th, 2002, 07:11 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
I think you really meant
Code:
if ((($first != "+") AND ($first != "-")) AND (($last != "+") AND ($last != "-"))) {
....
}
|

October 15th, 2002, 07:20 PM
|
|
Junior Member
|
|
Join Date: Jul 2002
Location: Pozarevac, Yugoslavia
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
$first is first character of string, and $last is last character of string... i mean that first character of string must not be "+" or "-" and last character must not be "+" or "-"....how do i write it?
|

October 15th, 2002, 07:21 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Yep, the statement that I posted above would work. Also you could remove some parenthesis if you like 
|

October 16th, 2002, 02:36 AM
|
|
Junior Member
|
|
Join Date: Jul 2002
Location: Pozarevac, Yugoslavia
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
 thnanx, works! (but, i do not understand why don't work my algorithm...i write like i say my if clause)
could i write it in some other, better (algorithm) way?
|

October 16th, 2002, 06:07 PM
|
|
|
|
You are checking to see if the first character is not '+' or not '-'. That will always evaluate to true since it has to not be at least one of them. The same holds true for the last character. Scorpions version checks to make sure that both the first and last characters are not '+' or '-'.
|

November 11th, 2002, 03:02 PM
|
 |
php-oriented object
|
|
Join Date: Jul 2001
Location: 0x9832053
Posts: 173
Time spent in forums: 24 m 49 sec
Reputation Power: 12
|
|
PHP Code:
if (($first!='+' OR $first!='-') AND ($last!='+' OR $last!='-'))
excuse me for the php code, but it gives some syntax hilight to the thing above.
hope this helps 
|

November 11th, 2002, 03:07 PM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
tank, as per Scorpions code above, they all need to be 'AND' conditions, not 'OR'.
|

November 11th, 2002, 03:17 PM
|
 |
php-oriented object
|
|
Join Date: Jul 2001
Location: 0x9832053
Posts: 173
Time spent in forums: 24 m 49 sec
Reputation Power: 12
|
|
wops...that's true! sorry
well....too late here...gotta go to bed now 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|