Check for valid

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Re: Check for valid

Post by ROBROS » Thu Sep 28, 2017 9:37 am

Hi Serge,
thx for your reply,
I have a Main.prg with function main and a main window win_1 and a second window win_2 (not main).
To keep the app more readable I decided to define any further window in separate prg-files outside the main.prg.
But I get this syntax-error, though the only change of the code in my initial post is, that I removed the semicolon and the main-statement.

I set windowtype to child. Do I have to set another windowtype?
When I come home from work I will send the source code.

Robert

edk
Posts: 166
Joined: Thu Oct 16, 2014 11:35 am
DBs Used: DBF
Location: Poland
Has thanked: 44 times
Been thanked: 98 times

Post by edk » Thu Sep 28, 2017 9:52 am

Remember about #include <hmg.ch> in all .prg

Main.prg

Code: Select all

#include <hmg.ch>

Function Main

DEFINE WINDOW Main ; 
AT 90,90 ; 
WIDTH 400 ; 
HEIGHT 250 ; 
TITLE "MAIN" ; 
MAIN 

@10,10 BUTTON b_1 CAPTION "Form_1" ACTION form_1()

END WINDOW

ACTIVATE WINDOW Main

RETURN NIL
Form1.prg

Code: Select all

#include <hmg.ch>

Function form_1

local cMon, cYear

IF IsWindowDefined(Form_1)
	DoMethod ('Form_1' , 'SetFocus')
	RETURN Nil
ENDIF


set navigation extended

DEFINE WINDOW Form_1 ; 
AT 90,500 ; 
WIDTH 400 ; 
HEIGHT 250 ; 
TITLE "Year/Month"

@ 20,20 LABEL lbl1 ; 
PARENT Form_1 ; 
VALUE "Monat 2-stellig" //month 2 digits


@ 20,150 LABEL lbl2 ; 
PARENT Form_1 ; 
VALUE "Jahr 4-stellig" //year 4 digits

@ 40,20 TEXTBOX Text_1 ;
parent Form_1;
value cMon;
inputmask "99" On LostFocus chkmon() On Enter chkmon()


@ 40,150 TEXTBOX Text_2; 
PARENT Form_1;
value cYear;
inputmask "9999" On LostFocus chkYear() On Enter chkyear()

@ 150,20 LABEL lbl3 value 'Ende mit F-10';
     FONTCOLOR BLUE

on key F10 action fill_MonYear()

END WINDOW

ACTIVATE WINDOW Form_1 
close databases

RETURN NIL

function fill_MonYear
SetProperty('Form_1','text_1','Value',GetProperty('Form_1','Text_1','Value'))
cMon:=GetProperty('Form_1','Text_1','Value')
SetProperty('Form_1','text_2','Value',GetProperty('Form_1','Text_2','Value'))
cYear:=GetProperty('Form_1','Text_2','Value')
pend()
return

function pend
MsgInfo( cMon+'/'+cYear)
release Window Form_1 
return


function chkmon
use mon // this table contains all valid values for cMon
index on mon to mon
seek Form_1.Text_1.value
if !found()
   MsgInfo('Only 01 - 12 allowed')
   //Form_1.Text_1.value:="  "
   Form_1.Text_1.SetFocus
endif
return

function chkyear
if val(Form_1.Text_2.value)>year(date())
   MsgInfo('Only current or former years allowed')
   //Form_1.Text_2.Value:="    "
   Form_1.Text_2.SetFocus
endif
return 

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Post by ROBROS » Thu Sep 28, 2017 11:16 am

I'm not sure,but maybe I have really not included hmg.ch.
I will see,when I come home from work.
Thank you.

ROBROS
Posts: 60
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Has thanked: 32 times
Been thanked: 1 time

Post by ROBROS » Thu Sep 28, 2017 1:28 pm

Shame on me :cry:
I have to apologize, indeed I had forgotten to include hmg.ch.
Now evrything is ok.
The 'syntax error'-message was misleading me, brought me on the wrong track.

Thank you for your changes of my code.

Robert

Post Reply