Lazarus

Programming => Packages and Libraries => Ported from Delphi/Kylix => Topic started by: typo on December 12, 2014, 03:04:12 pm

Title: Problem porting OpenC2Pas
Post by: typo on December 12, 2014, 03:04:12 pm
I am getting an external exception here:

Code: [Select]
var
   Identifier :AnsiString;
   DataType : array [0..DataTypesCount-1, 0..1] of PChar = (...);
begin
  for n := 1 to DataTypesCount do
                  if Identifier = DataType[n, 0] then   // EXCEPTION HERE
                  begin
                  {...}
                  end;
{...}
end;

The exception refers to a PChar to AnsiString conversion. Any idea?
Title: Re: Problem porting OpenC2Pas
Post by: typo on December 12, 2014, 03:24:14 pm
Well, I solved it with a simple:

Code: [Select]
if PCHAR(Identifier) = DataType[n, 0] then
Title: Re: Problem porting OpenC2Pas
Post by: typo on December 12, 2014, 03:47:13 pm
Attached is the converted project (64Kb).
Title: Re: Problem porting OpenC2Pas
Post by: birin on December 12, 2014, 06:06:28 pm
Hello typo,

I see another bug in your code :
The intervals of the array and the loop are differents, respectively 0..DataTypesCount - 1 and 1..DataTypesCount.
Title: Re: Problem porting OpenC2Pas
Post by: typo on December 12, 2014, 06:10:02 pm
Tnanks, but the code is not mine. I only converted it.
TinyPortal © 2005-2018