Recent

Author Topic: TEdit not editable  (Read 4239 times)

wp

  • Hero Member
  • *****
  • Posts: 12793
Re: TEdit not editable
« Reply #15 on: December 10, 2020, 07:54:14 pm »
  • Next compilation attempt: "Duplicate identifier "Disc"" in unit DiscImage. OK, there is a property Disc with the same name as this local variable; mode ObjFPC does not accept this. To fix this and all other issues of this kind I opened the project options > "Compiler options" > "Parsing" and selected "Delphi (-MDelphi)" in the "Syntax mode" combo box.
In my process to migrate it away from being MDelphi, I found the same error. Initially I changed the identifier name to "Disk", before I realised I had been stupid originally and could have just used "Result", and remove the identifier declaration completely.
In such cases I normally put a lower-case L in front of the local identifier ('l" = "local"). And this removes the ambiguity.

TDirectory is defined in the DiscImage unit. It is my own definition.
I used the DiscImage unit from your website, it does not contain a TDirectory.

Another oddity (and I know this is going off topic) I've found is with the function:
function TMainForm.IntToStrComma(size: Int64): String;
begin
 Result:=Format('%.0n',[Real(size)]);
end;

With {$MODE MDelphi} it returns 0, no matter what 'size' is set to (bearing in mind this works on Delphi). But change to {$MODE objFPC} and it works fine - returns a number (as a string) with thousands separators.
I don't know, but I almost never use the old "real" type which confuses me with Turbo Pascal. Maybe it does not work when "real" requires less bytes than Int64. I would simply multiply Size by 1.0 - this works always, for sure:
Code: Pascal  [Select][+][-]
  1.  Result := Format('%.0n', [1.0*size]);

geraldholdsworth

  • Full Member
  • ***
  • Posts: 226
Re: TEdit not editable
« Reply #16 on: December 10, 2020, 08:38:14 pm »
I used the DiscImage unit from your website, it does not contain a TDirectory.
Yep - you are absolutely correct. It's been a long day! :o
I also changed that to CreateDir. Is it bedtime yet?

 

TinyPortal © 2005-2018