Recent

Author Topic: Compiler syntax error  (Read 2410 times)

pigpigpig

  • Newbie
  • Posts: 2
Compiler syntax error
« on: July 15, 2015, 10:26:29 am »
Sorry! my English is poor. and I'm a Lazarus Beginner.

I write a program like: (open a doc and goto bookmark )

Procedure Word_Goto_Bookmark( aWordDoc , aBookMark, Fill_String;String);
Var oW : Variant;
Begin
    oW:=CreateOleObject('Word.Application');
    oW.documents.Open( aWordDoc ,TRUE);
    oW.Visible:=True;
    If oW.ActiveDocument.Bookmarks.Exists( aBookMark ) Then
   Begin
      oW.Selection.goto(-1,,,aBookMark); //Lazarus Error But Delphi OK.
      oW.Selection.TypeText(Fill_String);
   End;
End;

in Delphi Compiler & Run OK.

But in FPC / codeTyphone / Lazarus Compiler say  Syntax Error, "identifier" excepted but "GOTO" found

How Can I slove the problem? Thank!
 

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11445
  • FPC developer.
Re: Compiler syntax error
« Reply #1 on: July 15, 2015, 10:29:51 am »
This is normal. COM identifiers can match reserved identifiers. The standard solution is to add a "&"  (so Selection.&Goto ) to signal the parser the reserved meaning of the identifier is not meant.

I don't know if that is a FPC 2.6.x or a 3.x version, and if it works in all modes (it should work in mode delphi, since it is a Delphi feature)

pigpigpig

  • Newbie
  • Posts: 2
Re: Compiler syntax error
« Reply #2 on: July 31, 2015, 04:40:41 am »
This is normal. COM identifiers can match reserved identifiers. The standard solution is to add a "&"  (so Selection.&Goto ) to signal the parser the reserved meaning of the identifier is not meant.

I don't know if that is a FPC 2.6.x or a 3.x version, and if it works in all modes (it should work in mode delphi, since it is a Delphi feature)

Program Compile OK,Thanks!

 

TinyPortal © 2005-2018