Recent

Author Topic: Error: Illegal qualifier in converting Delphi unit  (Read 9406 times)

vfclists

  • Hero Member
  • *****
  • Posts: 823
    • HowTos Considered Harmful?
Error: Illegal qualifier in converting Delphi unit
« on: March 14, 2010, 07:10:03 pm »
Hi guys,

I am trying to compile the TVersionInfo component by Anders Melander
at http://melander.dk/articles/versioninfo/.

It defines the structure below

type
 TTranslationRec = packed record
   case Integer of
   0: (
     LanguageID: WORD;
     CharsetID: WORD);
   1: (
     TranslationID: DWORD);
 end;
 PTranslationRec = ^TTranslationRec;
 TTranslationTable = array[0..0] of TTranslationRec;
 PTranslationTable = ^TTranslationTable;


which causes the compiler error

VersionInfo.pas(141,37) Error: Illegal qualifier

function TVersionInfo.GetCharset(Index: integer): WORD;
begin
 Result := TranslationTable[Index].CharsetID;
end;

Is there a way to convert for Free Pascal compatibility?

Windows - Lazarus 1.0.8/FPC 2.6.0
Linux - Lazarus 1.4.4 /FPC 2.6.4

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 833
    • Burdjia
Re: Error: Illegal qualifier in converting Delphi unit
« Reply #1 on: March 15, 2010, 08:21:40 am »
What is the type of TranslationTable?
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Zoran

  • Hero Member
  • *****
  • Posts: 1283
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Error: Illegal qualifier in converting Delphi unit
« Reply #2 on: March 15, 2010, 01:30:30 pm »
The variable TranslationTable seems not to be declared.

Somwhere in code the variable has to be declared:
Code: [Select]
var
  TranslationTable: TTranslationTable;
Then, this array has to be initialized somewhere.

Or it's a constant, which also must be declared and initialized:
Code: [Select]
const
  TranslationTable: TTranslationTable = [ , , , ...]; // <- some actual list of values

mas steindorff

  • Sr. Member
  • ****
  • Posts: 397
Re: Error: Illegal qualifier in converting Delphi unit
« Reply #3 on: March 15, 2010, 11:03:17 pm »
this code works for me
Code: [Select]
...
Implementation
  Uses    windows   ;

function TFMainform.myGetVersion(filename:string=''): String;
var
  my :record
    Dummy: DWord;
    VerInfo: Pointer;
    VerInfoSize: DWord;
    VerValueSize: DWord;
    VerValue:  PVSFixedFileInfo;
    end;
begin
  Result:='';
  my.Dummy:=0; // to keep the compiler happy
  if filename='' then filename:=ParamStr(0);
  my.VerInfoSize := GetFileVersionInfoSize(PChar(filename), my.Dummy);
  if my.VerInfoSize=0 then
     exit;
  GetMem(my.VerInfo, my.VerInfoSize);
  GetFileVersionInfo(PChar(filename), 0, my.VerInfoSize, my.VerInfo);
  VerQueryValue(my.VerInfo, '\', Pointer(my.VerValue), my.VerValueSize);
  with my.VerValue^ do  begin
     result := IntTostr(dwFileVersionMS shr 16);
     result := result+'.'+   IntTostr(dwFileVersionMS and $FFFF);
     result := result+'.'+   IntTostr(dwFileVersionLS shr 16);
     result := result+'.'+   IntTostr(dwFileVersionLS and $FFFF);
  end;
  FreeMem(my.VerInfo, my.VerInfoSize);
end;
{ TFMainform }

Procedure TFMainform.FormCreate(Sender: TObject);

Begin
   RevStr := 'Rev:' + myGetVersion('');
end;
windows 7/10 - laz v1.2.6 fpc 2.6.4 & 2.0RC2