Recent

Author Topic: Problem porting OpenC2Pas  (Read 4066 times)

typo

  • Hero Member
  • *****
  • Posts: 3051
Problem porting OpenC2Pas
« 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?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Problem porting OpenC2Pas
« Reply #1 on: December 12, 2014, 03:24:14 pm »
Well, I solved it with a simple:

Code: [Select]
if PCHAR(Identifier) = DataType[n, 0] then

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Problem porting OpenC2Pas
« Reply #2 on: December 12, 2014, 03:47:13 pm »
Attached is the converted project (64Kb).

birin

  • New member
  • *
  • Posts: 9
Re: Problem porting OpenC2Pas
« Reply #3 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.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Problem porting OpenC2Pas
« Reply #4 on: December 12, 2014, 06:10:02 pm »
Tnanks, but the code is not mine. I only converted it.

 

TinyPortal © 2005-2018