add to window from procedure

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
tomfromdare
Posts: 6
Joined: Mon Dec 15, 2008 4:28 pm

add to window from procedure

Post by tomfromdare » Mon Dec 15, 2008 4:52 pm

Anyone:

I've got my first hmg program functional, but when adding a procedure, called from a button, I get an error that I haven't been able to solve. I've read lots of sample programs, and many forum posts, but don't see what is wrong.

...here is end of main() :
nTextTop += nTextIncr
@ nTextTop,70 BUTTON Button_1 CAPTION "Update" WIDTH 70 HEIGHT 26 ACTION DoUpdate()
@ nTextTop,270 BUTTON Button_2 CAPTION "Not now" WIDTH 70 HEIGHT 26 ACTION MsgInfo('Skip')
READ

endif
END WINDOW

CENTER WINDOW Form_1

ACTIVATE WINDOW Form_1 // this is line 176
Return

PROCEDURE DoUpdate
// copy net file to local dir
nTextTop += nTextIncr
@ nTextTop,nTextLeft LABEL Label_Seven ;
VALUE "Copying files..." ;
WIDTH 450 ;
HEIGHT 27 ;
FONT "Arial" SIZE 10 ;
FONTCOLOR BLACK BOLD // this is line 187
COPY FILE (NETWORK_DRIVE + NETWORK_DIRECT + EXECUTABLE_NAME) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_TWO )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_THREE )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_FOUR )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_FIVE )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_SIX )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_SEVEN )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_EIGHT )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_NINE )
COPY FILE (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_ONE) ;
TO (LOCAL_DRIVE + LOCAL_DIRECT + EXECUTABLE_NAME_TEN )
nTextTop += nTextIncr
@ nTextTop,nTextLeft LABEL Label_Eight ;
VALUE "Copy Completed --- press any key..." ;
WIDTH 450 ;
HEIGHT 27 ;
FONT "Arial" SIZE 10 ;
FONTCOLOR BLACK BOLD
// inkey(0)
RETURN
----------------------------------------------------------
Error BASE/1081 Argument error: +
Called from _ISWINDOWDEFINED(2540)
Called from _DEFINELABEL(87)
Called from DOUPDATE(187)
...
Called from MAIN(176)
-----------------------------------------------
making some vars PUBLIC did not help:
PUBLIC Form_1, Label_Seven, Label_Eight
PUBLIC nTextTop := 28, nTextLeft := 22, nTextIncr := 24, cLabelText
The sample programs often MODIFY some property, but can't a procedure also ADD to the existing window? Any suggestion is appreciated!

Tom

User avatar
esgici
Posts: 4472
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 352 times
Been thanked: 104 times
Contact:

Post by esgici » Mon Dec 15, 2008 10:36 pm

tomfromdare wrote: I've got my first hmg program functional, but when adding a procedure, called from a button, I get an error that I haven't been able to solve.
----------------------------------------------------------
Error BASE/1081 Argument error: +
Called from _ISWINDOWDEFINED(2540)
Called from _DEFINELABEL(87)
Called from DOUPDATE(187)
...
Called from MAIN(176)
-----------------------------------------------

Tom
Hi Tom, Welcome :)

I guess that your DoUpdate procedure is in a separate ( other than Main Window defined ) .prg file.

If so, you have add

#include <minigui.ch>

and

DECLARE WINDOW Form_1

statements to beginning of that file.

Happy HMG'ing.

Regards

--

esgici
Viva INTERNATIONAL HMG :D

User avatar
Alex Gustow
Posts: 290
Joined: Thu Dec 04, 2008 1:05 pm
Location: Yekaterinburg, Russia
Contact:

Post by Alex Gustow » Tue Dec 16, 2008 5:45 am

Hi tomfromdare!
It's simple mistake for newbies (and for me too :) )

Look at this line:

Code: Select all

@ nTextTop,nTextLeft LABEL Label_Seven ;
  VALUE "Copying files..." ;
  WIDTH 450 ;
  HEIGHT 27 ;
  FONT "Arial" SIZE 10 ;
  FONTCOLOR BLACK BOLD // this is line 187
It's really mistake - you define label (or other control) outside from window definition... and don't write - in which window it must be?..

Write something like this:

Code: Select all

@ nTextTop,nTextLeft LABEL Label_Seven ;
  OF Win_1 ;   // <-- if your main window name is "Win_1"
  VALUE "Copying files..." ;
  WIDTH 450 ...... etc
and it must work (I think)

User avatar
Rathinagiri
Posts: 5250
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 167 times
Been thanked: 165 times
Contact:

Post by Rathinagiri » Tue Dec 16, 2008 6:58 am

Yes. You got it I think!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

tomfromdare
Posts: 6
Joined: Mon Dec 15, 2008 4:28 pm

Post by tomfromdare » Thu Dec 18, 2008 5:15 pm

Alex:

Great --- adding "OF Form_1 ;" to each of the label statements worked! The errors are gone, and the program runs to completion.

(the whole program is in a single .prg file )

Thanks to all,
Tom

Post Reply