Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple String Problem

Status
Not open for further replies.

Jamesis

Programmer
May 5, 2009
7
CA
Hello! I've ran into a rather small problem that I can't solve. I get an error when I try to see if my string = to ' '?

At first I had:
------------
tmpPos : string;
tmpSize : string;
..
if (tmpPos = ' ' or tmpSize = ' ' ) then
..
..
end;
-----------

however, the above doesn't work.. I get the error

------
Operator not applicable to this operand type.
------

Any ideas what I must do to see if my string equals ' '?? Any help would be appreciated
 
Okay, so apparently, delphi tells me that I've got incompatible types because I'm missing brackets.

Its fixed, just need brackets around each or statment.. sorry new to Delphi
 
Its fixed, just need brackets around each or statment.. sorry new to Delphi

Code:
if (tmpPos = ' ' or tmpSize = ' ' ) then

In case you would like to know why (being new to Delphi and all), it's because that word "or" is a bitwise operator. In the order of operations, bitwise ops are the highest thing. So your code was asking to evaluate (' ' or tmpsize) first, which doesn't make any sense and the compiler is putting out a message indicating such.

Depending on the case, if you are working with something that makes sense, you will either get the same message, or you will get incorrect results.

Measurement is not management.
 
Ahh thanks for the explanation, I thought I could get away with this in Java at least
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top