Recent

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

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • 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?

Lazarus 3.0/FPC 3.2.2

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • 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: 1830
    • 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

  • Hero Member
  • *****
  • Posts: 532
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 10 &11, Ubuntu 21+ - fpc 3.0.4, IDE 2.0 general releases

 

TinyPortal © 2005-2018