Thread: if stra[1] <> strb[1] - "Operator not applicable to this operand type"
 |
This question is not answered.
Helpful answers available: 2.
Correct answers available: 1.
|
|
Replies:
4
-
Last Post:
Apr 2, 2018 3:12 PM
Last Post By: Remy Lebeau (Te...
|
Threads:
[
Previous
|
Next
]
|
|
Posts:
4
Registered:
4/5/18
|
|
This is condensed from GraphicEx from the Virtual Tree View people.
If I compile the following (in Tokyo)
var
ZLIB_VERSION: String[10] = '1.1.2';
s: string;
procedure TForm1.FormClick(Sender: TObject);
begin
s := 'hello world';
if s[1] <> ZLIB_VERSION[1] then // <-- dcc32 Error E2015
...
I get the compiler error
"Operator not applicable to this operand type"
Edited by: Ken Knopfli on Apr 2, 2018 1:46 AM
|
|
|
Posts:
1,227
Registered:
12/16/99
|
|
Ken Knopfli wrote:
This is condensed from GraphicEx from the Virtual Tree View people.
If I compile the following (in Tokyo)
var
ZLIB_VERSION: String[10] = '1.1.2';
s: string;
procedure TForm1.FormClick(Sender: TObject);
begin
s := 'hello world';
if s[1] <> ZLIB_VERSION[1] then // <-- dcc32 Error E2015
...
I get the compiler error
"Operator not applicable to this operand type"
It compiles with typecast:
if s[1] <> Char(ZLIB_VERSION[1]) then
The legacy string[N] type contains ANSI characters while the standard
string type contains Unicode (UTF16) characters. Looks like there is no
automatic type conversion between ANSI and Unicode anymore in
statements like your original.
--
Peter Below
TeamB
|
|
|
|
Posts:
9,447
Registered:
12/23/01
|
|
Peter Below wrote:
Looks like there is no automatic type conversion between ANSI and
Unicode anymore in statements like your original.
There never was, for individual characters. Only for whole strings.
--
Remy Lebeau (TeamB)
|
|
|
|
Posts:
4
Registered:
4/5/18
|
|
The above is from the MZLib.pas unit from Mike Lischke's GraphicEx library,
function DeflateInt2,
Would that mean GraphicEx never compiled?
|
|
|
|
Posts:
9,447
Registered:
12/23/01
|
|
Ken Knopfli wrote:
The above is from the MZLib.pas unit from Mike Lischke's GraphicEx
library,
function DeflateInt2,
Would that mean GraphicEx never compiled?
More likely, you are trying to compile a version of GraphicEx that is
intended for pre-Unicode versions of Delphi. Make sure you are
compiling the right version.
--
Remy Lebeau (TeamB)
|
|
|
|
Legend
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|
Connect with Us