MichaelHooker
Programmer
OK, it's a dumb question. Delphi 7 PE, WinXP. A procedure in my latest project declares a variable N as a String.
The variable then gets its value from an index to another string, as in:
N then goes through a lot of processing until it's time to put it back where it came from:
However, the compiler does not like this, reporting:
when it gets to the line where N is fed back in to the string. It doesn't mind taking the single character element out of the string and putting it into var N, it just doesn't like putting it back again.
I can get around this by declaring N and O as Char types in the first place, though I was also trying to use them for expressions like:
I'll just have to use different variables. I can see many other ways around this, and I'm not asking for solutions. I'm just puzzled as to why Delphi will assign a single character from one string to another string, but won't do the reverse. I can't find any StrToChar or CharToStr functions, so you would think that no user conversion is ever contemplated.
So what's going on here and why?
Many thanks.
Michael Hooker
The variable then gets its value from an index to another string, as in:
Code:
N := String[25];
N then goes through a lot of processing until it's time to put it back where it came from:
Code:
String[25] := N;
However, the compiler does not like this, reporting:
Code:
Incompatible types: 'Char' and 'String'
I can get around this by declaring N and O as Char types in the first place, though I was also trying to use them for expressions like:
Code:
N := LeftStr(String, 5);
So what's going on here and why?
Many thanks.
Michael Hooker