once again I am asking for your help. The user should key in via 2 Textbox controls month and year. With inputmask and ON LostFocus and ON ENTER
the valid input is checked, works. See the following lines of code:
BTW: How can I put these lines of code into a kind of frame in which you can scroll up and down, as I have seen so often?
Code: Select all
#include <hmg.ch>
Function Main
local cMon, cYear
set navigation extended
DEFINE WINDOW Form_1 ;
AT 90,90 ;
WIDTH 400 ;
HEIGHT 250 ;
TITLE "Year/Month" ;
MAIN
@ 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
But in case the input is incorrect, MsgInfo() shows up twice
Who can explain that?
Kind Regards
Robert
Fun with programming HMG is increasing.