The BROWSE control and VALIDMESSAGES

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
TopsMarc
Posts: 80
Joined: Wed Apr 06, 2016 5:57 am
Location: Belgium (Flanders)

The BROWSE control and VALIDMESSAGES

Post by TopsMarc »

I'm further experimenting with the GRID and BROWSE control.

On validating data, is it possible to have more then one message for one column ?
I wrote this :

DEFINE BROWSE Browse_PRV
...
FIELDS {'LndID','PrvID','PrvNm' }
VALID { {||Nil} , {||Nil} , { || PRV_IsOK () }
VALIDMESSAGES { , , 'Invalid name'}
WHEN { {||.F.} , {||.F.}, {||.T.} }
...
END BROWSE

FUNCTION PRV_IsOK()
IF EMPTY(MemVar.PRV.PrvNm) .or. MemVar.PRV.PrvNm == "A"
RETURN .F.
ENDIF
RETURN .T.

If the name (3th column) is blanc or = 'A', I get the message 'Invalid name'. That works.

But how do I get this :
If the name is blanc, the message should be 'Blanc name'
If the name is 'A', the message shoud be 'A not allowed'

I tried a codeblock or a function in VALIDMESSAGES, but I failed.
I tried with 2 messageboxes in my function and set VALIDMESSAGES { , , }, but then I got my message and a default BROWSE message 'Invalid entry' too. I don't want 2 messages.

Is there any solution ?

Kind regards, Marc
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: The BROWSE control and VALIDMESSAGES

Post by bpd2000 »

Use Do Case
BPD
Convert Dream into Reality through HMG
User avatar
pctoledo
Posts: 123
Joined: Wed Aug 25, 2010 10:45 am
Location: Araçatuba - SP - Brazil
Contact:

Re: The BROWSE control and VALIDMESSAGES

Post by pctoledo »

a suggestion...

DEFINE BROWSE Browse_PRV
...
FIELDS {'LndID','PrvID','PrvNm' }
VALID { {||Nil} , {||Nil} , { || PRV_IsOK () }
WHEN { {||.F.} , {||.F.}, {||.T.} }
...
END BROWSE

FUNCTION PRV_IsOK()
IF EMPTY(MemVar.PRV.PrvNm)
MsgInfo('Blanc name')
RETURN .F.
ENDIF
IF MemVar.PRV.PrvNm == "A"
MsgInfo('A not allowed')
RETURN .F.
ENDIF
RETURN .T.
Regards/Saludos,

Toledo

Clipper On Line
User avatar
TopsMarc
Posts: 80
Joined: Wed Apr 06, 2016 5:57 am
Location: Belgium (Flanders)

Re: The BROWSE control and VALIDMESSAGES

Post by TopsMarc »

Thank you for your suggestions, but I did try already the MsgInfo in my function and set VALIDMESSAGES { , , }
Then I got the correct error message followed by the standard BROWSE message 'Invalid entry'. I don't want 2 messages.
Do you have other suggestions ?
Kind regards, Marc
User avatar
TopsMarc
Posts: 80
Joined: Wed Apr 06, 2016 5:57 am
Location: Belgium (Flanders)

Re: The BROWSE control and VALIDMESSAGES

Post by TopsMarc »

To pctoledo, In attachment a movie InvalidEntry to demonstrate that I then get 2 messages. I only want my own message.
But it was a nice suggestion.
Kind regards, Marc
Attachments
InvalidEntry.zip
(560.9 KiB) Downloaded 202 times
User avatar
pctoledo
Posts: 123
Joined: Wed Aug 25, 2010 10:45 am
Location: Araçatuba - SP - Brazil
Contact:

Re: The BROWSE control and VALIDMESSAGES

Post by pctoledo »

other suggestion:

Code: Select all

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 800 ;
		HEIGHT 510 ;
		TITLE 'Test Browse' ;
		MAIN 

		USE PRV NEW
		INDEX ON LNDID TO PRV

		@ 10,10 BROWSE Browse_PRV ;
			WIDTH 770 ;
			HEIGHT 440 ;
			HEADERS {'LndID','PrvID','PrvNm' } ;
			WIDTHS {100,100,220} ;
			WORKAREA PRV ;
			FIELDS {'LndID','PrvID','PrvNm' } ;
			VALID { {||Nil} , {||Nil} , { || PRV_IsOK () } } ;
			WHEN { {||.F.} , {||.F.}, {||.T.} } ;
			EDIT
		
	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

	_HMG_SYSDATA [ 136 ][11] := 'Invalid entry'

Return

FUNCTION PRV_IsOK()
IF EMPTY(MemVar.PRV.PrvNm)
  _HMG_SYSDATA [ 136 ][11] := 'Blanc name'
  RETURN .F.
ENDIF
IF MemVar.PRV.PrvNm == "A"
  _HMG_SYSDATA [ 136 ][11] := 'A not allowed'
  RETURN .F.
ENDIF
RETURN .T.
Regards/Saludos,

Toledo

Clipper On Line
User avatar
TopsMarc
Posts: 80
Joined: Wed Apr 06, 2016 5:57 am
Location: Belgium (Flanders)

Re: The BROWSE control and VALIDMESSAGES

Post by TopsMarc »

Hi pctoledo,

I am pleasantly surprised , it works perfectly. Thank you very much for your solution.

Kind regards, Marc
Post Reply