Page 1 of 1

Syntax Error

Posted: Thu Aug 05, 2010 7:10 am
by cocoking
Why do I get these syntax errors:

Compiling 'reindex.prg'...
reindex.prg(28) Error E0030 Syntax error "syntax error at '@'"
reindex.prg(30) Error E0030 Syntax error "syntax error at '.'"
reindex.prg(63) Error E0030 Syntax error "syntax error at '.'"
reindex.prg(65) Error E0030 Syntax error "syntax error at '.'"
reindex.prg(67) Error E0030 Syntax error "syntax error at '.'"

from the following statements (with focus on lines 23-30):

14 #include "i_ini.ch" // define CRLF
15
16 ************************************************************************
17 function Reindex(nSubChoice)
18 *************************************************************************
19 // reindex system files
20 // 2010-08-01 revised to conform to hmg
21
22 // preparing the editbox
23 @ 10, 10 EDITBOX ebRein ;
24 OF PARENT MainForm ;
25 WIDTH 300 ;
26 HEIGHT 300 ;
27 VALUE "Reindexing files:" + CRLF ;
28 READONLY
29
30 MainForm.ebRein.Show
...
57 // reindex file 1
58 if file("sss&cyear..dbf")
59 if DbOpen(1, "sss&cyear", .F.)
60 index on empnumbr to sss&cyear
61 dbclosearea()
62 endif
63 MainForm.ebRein.Value += "SSS " + cYear + " file..." + CRLF
64 else
65 MainForm.ebRein.Value += "No SSS file for " + cYear + "." + CRLF
66 endif
67 MainForm.ebRein.Refresh

The purpose here is to display/log the indexing process into an editbox while indexing is going on (though I'm not sure if this will work as I can't get pass statements 23-30)
Any idea or suggestions?

Re: Syntax Error

Posted: Thu Aug 05, 2010 8:08 am
by mol
I think you need to declare window MainForm (isn't it defined in another module?).
Please, add this line to the top of module:

Code: Select all

declare window MainForm

Re: Syntax Error

Posted: Thu Aug 05, 2010 8:54 am
by cocoking
Thank you for your reply.

I have this in the main program:

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 750 ;
HEIGHT 700 ;
MAIN;
TITLE 'HMMGC Payroll System'

DEFINE MAIN MENU
...
END MENU
END WINDOW

The main form and the menu are working.

Re: Syntax Error

Posted: Thu Aug 05, 2010 9:16 am
by Rathinagiri
Hi,

The problem may be in this line.

24 OF PARENT MainForm ;

You can use either "OF" or "PARENT" and not both!

So, it should be,

24 OF MainForm ;

or

24 PARENT MainForm ;

Re: Syntax Error

Posted: Thu Aug 05, 2010 9:46 am
by cocoking
Thank you, Mr. Rathinagiri, your suggestion to use PARENT MainForm worked. I'm sorry I missed the vertical bar (|) in the syntax definition of EDITBOX.

The syntax errors in lines, 63, 65, 67 remain but I feel I'm progressing in my understanding of HMG and so is my confidence in using it.

TYVM

Re: Syntax Error

Posted: Thu Aug 05, 2010 12:50 pm
by Rathinagiri
Why can't you try


63:MainForm.ebRein.Value := MainForm.ebRein.Value + "SSS " + cYear + " file..." + CRLF

65:MainForm.ebRein.Value := MainForm.ebRein.Value + "No SSS file for " + cYear + "." + CRLF

67. You need not enter this line.

Re: Syntax Error

Posted: Fri Aug 13, 2010 10:22 am
by cocoking
Yes, Marek is correct in his suggestion to add DECLARE WINDOW when form is used in a different PRG from where it was defined.

Rathi is also right in his suggestion not to use += in the assignment statement but instead use :=.
Additionally, when I used =, it resulted in syntax error.

Thank you very much, Marek and Rathi for your help.

Sorry for the late reply, I just had an official business trip and wasn't able to work on it for a while.