Recent

Author Topic: Conversion problem  (Read 5156 times)

typo

  • Hero Member
  • *****
  • Posts: 3051
Conversion problem
« on: August 27, 2014, 05:29:40 pm »
I am trying to convert Delphi_OOo_v12en ( http://sourceforge.net/projects/ooomacros/files/Delphi%20OOo/Version%201.2/Delphi_OOo_v12en.zip/download ) project to Lazarus and have the following error message:

Quote
Error: Can't determine which overloaded function to call

on the following line of code:

Code: [Select]
{...}
case VarType(V1) of
    varEmpty: strV1:= mess307;
    varNull: strV1:= mess306;
    varByte: strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 2) + ' )'; // ERROR HERE
    varSmallInt, varWord: strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 4) + ' )';
    varInteger, varLongWord:  strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 8) + ' )';
    varInt64, varDecimal: strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 16) + ' )';
    varDouble, varSingle: strV1:= FloatToStr(V1);
    varBoolean: strV1:= BoolToStr(V1, True);
    varString, varStrArg, varOleStr: begin strV1:= V1; typeV1:= XrayMstring; end;
    varDispatch: pre_analyze_Object;
    else       
   {...}                     

on IntToHex function where V1 is of type Variant. Any idea?
« Last Edit: August 27, 2014, 05:33:51 pm by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Conversion problem
« Reply #1 on: August 27, 2014, 05:42:19 pm »
Another error on the line below:

Code: [Select]
{...}
firstLine.CellBackColor:= RGB(100, 255, 255);
    for x:= 0 to oneGrid.ColCount -1 do begin
      oneCol:= oneGrid.Cols[x];
      for y:= 0 to oneCol.Count -1 do begin
        if oneCol.Strings[y] <> '' then begin
          myCell:= mySheet.getCellByPosition(x, y);
          myCell.String:= oneCol.Strings[y];  //ERROR HERE
        end;
        if (y mod 20) = 0   then  Application.ProcessMessages;
      end;
      myColumn:= mySheet.Columns.getByIndex(x);   
{...}

with the message:

Quote
Fatal: Syntax error, "identifier" expected but "STRING" found

where myCell is also of type Variant.
« Last Edit: August 27, 2014, 05:45:59 pm by typo »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Conversion problem
« Reply #2 on: August 27, 2014, 06:01:51 pm »
String is a reserved word, escape with & to resolve.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Conversion problem
« Reply #3 on: August 27, 2014, 06:04:05 pm »
how about
Code: [Select]
myCell.&String:= oneCol.Strings[y];
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Conversion problem
« Reply #4 on: August 27, 2014, 06:24:52 pm »
I am trying to convert Delphi_OOo_v12en
tested that FPC 2.7.1/Win64
Code: [Select]
IntToHex(V1, 2)
->
IntToHex(Longint(V1), 2)

myCell.String:= oneCol.Strings[y];
->
myCell.&String:= oneCol.Strings[y];

tabStopsList[0].DecimalChar:= ',';
-> 
tabStopsList[0].DecimalChar:= olevariant(','); 

After running it got error:

"Not enough storage is available.." in comobj.
Code: [Select]
Result:= OpenOffice.createInstance(serviceName);
->
Result:= OpenOffice.createInstance(olevariant(serviceName));

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Conversion problem
« Reply #5 on: August 27, 2014, 06:32:48 pm »
Yes, I have the same error.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Conversion problem
« Reply #6 on: August 27, 2014, 06:55:53 pm »
Timewarp's last suggested change [olevariant(servicename)] solved the "not enough storage" error for me (Win7, 32-bit), and opened a new LibreOffice document with a Hello World and lime green font colour.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Conversion problem
« Reply #7 on: August 27, 2014, 07:01:11 pm »
Done for me too.

Thanks.
« Last Edit: August 27, 2014, 07:22:56 pm by typo »

Basile B.

  • Guest
Re: Conversion problem
« Reply #8 on: August 28, 2014, 04:38:56 am »
I am trying to convert Delphi_OOo_v12en ( http://sourceforge.net/projects/ooomacros/files/Delphi%20OOo/Version%201.2/Delphi_OOo_v12en.zip/download ) project to Lazarus and have the following error message:

Quote
Error: Can't determine which overloaded function to call

on the following line of code:

Code: [Select]
{...}
case VarType(V1) of
    varEmpty: strV1:= mess307;
    varNull: strV1:= mess306;
    varByte: strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 2) + ' )'; // ERROR HERE
    varSmallInt, varWord: strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 4) + ' )';
    varInteger, varLongWord:  strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 8) + ' )';
    varInt64, varDecimal: strV1:= IntToStr(V1) + '  ( $' + IntToHex(V1, 16) + ' )';
    varDouble, varSingle: strV1:= FloatToStr(V1);
    varBoolean: strV1:= BoolToStr(V1, True);
    varString, varStrArg, varOleStr: begin strV1:= V1; typeV1:= XrayMstring; end;
    varDispatch: pre_analyze_Object;
    else       
   {...}                     

on IntToHex function where V1 is of type Variant. Any idea?

OT: as you convert you could do what the original dev had not: use e.g: varByte: strV1:= format( '%.d ( 0x%.2x)', [V1, V1]); instead of those concatenated string const.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Conversion problem
« Reply #9 on: August 28, 2014, 03:45:53 pm »
The partially converted project is here (attached). It is running fine.
« Last Edit: August 28, 2014, 04:00:15 pm by typo »

 

TinyPortal © 2005-2018