Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #12744 > unrolled thread

Validation in FieldSpec

Started byzodcomag@gmail.com
First post2020-01-05 14:17 -0800
Last post2020-01-18 14:10 -0500
Articles 14 — 5 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Validation in FieldSpec zodcomag@gmail.com - 2020-01-05 14:17 -0800
    Re: Validation in FieldSpec JohnMartens <martens@tennishulp.info> - 2020-01-06 06:50 +0100
      Re: Validation in FieldSpec zodcomag@gmail.com - 2020-01-06 03:40 -0800
        Re: Validation in FieldSpec JohnMartens <martens@tennishulp.info> - 2020-01-06 17:38 +0100
    Re: Validation in FieldSpec zodcomag@gmail.com - 2020-01-06 09:09 -0800
    Re: Validation in FieldSpec zodcomag@gmail.com - 2020-01-06 09:19 -0800
      Re: Validation in FieldSpec JohnMartens <martens@tennishulp.info> - 2020-01-06 18:50 +0100
        Re: Validation in FieldSpec zodcomag@gmail.com - 2020-01-06 11:41 -0800
          Re: Validation in FieldSpec JohnMartens <martens@tennishulp.info> - 2020-01-06 22:00 +0100
      Re: Validation in FieldSpec "Jamal" <noooospam@example.com> - 2020-01-06 17:25 -0500
        Re: Validation in FieldSpec zodcomag@gmail.com - 2020-01-07 02:57 -0800
          Re: Validation in FieldSpec "Jamal" <noooospam@example.com> - 2020-01-07 10:49 -0500
            Re: Validation in FieldSpec Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2020-01-07 17:28 +0100
              Re: Validation in FieldSpec James Martin <james@northwoodlumber.com> - 2020-01-18 14:10 -0500

#12744 — Validation in FieldSpec

Fromzodcomag@gmail.com
Date2020-01-05 14:17 -0800
SubjectValidation in FieldSpec
Message-ID<94a19123-e370-491b-bce2-8d47b741463e@googlegroups.com>
The variable is a SingleLineEdit

In the FieldSpec Editor (2,6 TPL version) of that control I states a min & max
What should I write for the "Validation" ?

If I write the FieldSpec by myself, how should I call the SetValidation() ?

Thanks
Henry

[toc] | [next] | [standalone]


#12745

FromJohnMartens <martens@tennishulp.info>
Date2020-01-06 06:50 +0100
Message-ID<quuhrj$ojs$1@dont-email.me>
In reply to#12744
I never used FieldSpec and validate in EditChange event

METHOD EditChange(oControlEvent) CLASS frmMyWindow
	SUPER:EditChange(oControlEvent)
	DO CASE
	CASE oControlEvent:Control:NameSym == #TheFieldToCheck
		.....
	ENDCASE
RETURN NIL



Op 5-1-2020 om 23:17 schreef zodcomag@gmail.com:
> The variable is a SingleLineEdit
> 
> In the FieldSpec Editor (2,6 TPL version) of that control I states a min & max
> What should I write for the "Validation" ?
> 
> If I write the FieldSpec by myself, how should I call the SetValidation() ?
> 
> Thanks
> Henry
> 

[toc] | [prev] | [next] | [standalone]


#12746

Fromzodcomag@gmail.com
Date2020-01-06 03:40 -0800
Message-ID<30ca697d-7a2d-4834-8fde-3be0bad1c283@googlegroups.com>
In reply to#12745
John Martens thanks

I find the EditChange() not an elegant solution.
- You have to be sure that it is not called before the control is fully built.
- It enters the errormessage few times.
- Debugging could end in an endloss loop.

That´s for is the FieldSpec, isn´t it?

Thanks
Henry

[toc] | [prev] | [next] | [standalone]


#12748

FromJohnMartens <martens@tennishulp.info>
Date2020-01-06 17:38 +0100
Message-ID<quvnpm$90o$1@dont-email.me>
In reply to#12746
CASE ! SELF:IsVisible()
can help to avoid getting into the check before content is changed by 
the user

The error message probelems are unknown to me

Debugging does not get me into an endless loop

I think I started using editchange because I have one place to do all 
checks eg 11-proof numbers, checking certain date ranges relative to 
current date, relations to content of other controls etc etc

John


Op 6-1-2020 om 12:40 schreef zodcomag@gmail.com:
> John Martens thanks
> 
> I find the EditChange() not an elegant solution.
> - You have to be sure that it is not called before the control is fully built.
> - It enters the errormessage few times.
> - Debugging could end in an endloss loop.
> 
> That´s for is the FieldSpec, isn´t it?
> 
> Thanks
> Henry
> 

[toc] | [prev] | [next] | [standalone]


#12749

Fromzodcomag@gmail.com
Date2020-01-06 09:09 -0800
Message-ID<694ff618-d7ed-421d-866c-efa3afd432d1@googlegroups.com>
In reply to#12744
Thanks for your reply

If I put the fo0llowing commands into Ed

if oControl # null_object .and. self:lPost .and. oControl:NameSym = #nNikotin
   if !Empty(oControl:VALUE)
      cVar := oControl:TextVALUE
      nVar := Val(cVar)
      if nVar < 0 .or. nVar > 14
         ErrorBox{self, "Max 14 mg/ml"}:Show()
         return nil
      endif	
   endif
endif
The ErrorMeddage is called twice
If I add 
   oControl:Value := 0
The ErrorMessage is still twice called, at least the value is now 0, and not illegal value.

If I add
   oControl:SetFocus()

[toc] | [prev] | [next] | [standalone]


#12750

Fromzodcomag@gmail.com
Date2020-01-06 09:19 -0800
Message-ID<dc0a8e47-95c7-46f9-96be-6e3d5cbc89e7@googlegroups.com>
In reply to#12744
COntinue...
If I add oControl:SetFocus()    // so the customer wilol stay on this control until it is legal
The ErrorMessage is called twice & the focus does not realy stays on the control.


It should be more logic to add the code into EditFocusChange(), because the value is checked after it is full, when maybe the first character is not legall, but after adding the second character it is legel.

When adding the code to EditFocusChange(), the ErrorBox is called 3 times.

It looks to me, that exactly for that exist the FieldSpec validation.

Thanks
Henry


   

[toc] | [prev] | [next] | [standalone]


#12751

FromJohnMartens <martens@tennishulp.info>
Date2020-01-06 18:50 +0100
Message-ID<quvs0o$6t9$1@dont-email.me>
In reply to#12750
Did you check what causes the errorbox to be called 3 times ?


Op 6-1-2020 om 18:19 schreef zodcomag@gmail.com:
> COntinue...
> If I add oControl:SetFocus()    // so the customer wilol stay on this control until it is legal
> The ErrorMessage is called twice & the focus does not realy stays on the control.
> 
> 
> It should be more logic to add the code into EditFocusChange(), because the value is checked after it is full, when maybe the first character is not legall, but after adding the second character it is legel.
> 
> When adding the code to EditFocusChange(), the ErrorBox is called 3 times.
> 
> It looks to me, that exactly for that exist the FieldSpec validation.
> 
> Thanks
> Henry
> 
> 
>     
> 

[toc] | [prev] | [next] | [standalone]


#12752

Fromzodcomag@gmail.com
Date2020-01-06 11:41 -0800
Message-ID<bb9a23da-385d-453e-9dc2-f6f7fea24741@googlegroups.com>
In reply to#12751
No, I haven't check.
Any idea how?

Henry

[toc] | [prev] | [next] | [standalone]


#12753

FromJohnMartens <martens@tennishulp.info>
Date2020-01-06 22:00 +0100
Message-ID<qv074k$ete$1@dont-email.me>
In reply to#12752
I do not know wether this is a proper way do do it but my app has a 
global debugging mode setting. When I want do debug and I would like 
extra info on the program stack then I call TestVersion(TRUE). 
Afterwards you can add an extra line in your code like this

IF TestVersion()
          ErrorBox{self, "Max 14 mg/ml"+GetPrgStack()}:Show()
ELSE
          ErrorBox{self, "Max 14 mg/ml"}:Show()
ENDIF

Then you will get the program stack and you can see which event fires 
the error box. Then you can decide which ones you want and which ones 
you want to avoid creating the error box by adding case of if statements 
in the EFC event of EC event

The GetPrgStack() will only work if you have compiler settings to 
compile ProcName and ProcLine into your app. You will find these in the 
properties setting ons the Compiler tab.

As I said, maybe this not the most elegant way to see where your app is 
but it works for me. Hope this wil help you a step ahead

John



FUNCTION TestVersion(lPar) AS LOGIC
	* function to read the parameter TestVersion
	* the value will be stored with the first call and the value will be 
given back all calls afterwards
	LOCAL STATIC lTestVersie := FALSE AS LOGIC
	IF PCount() = 1
		lTestVersie := lTestVersiePar
	ENDIF
RETURN lTestVersie



FUNCTION GetPrgStack() AS STRING
	* function to return the program calling stack
	LOCAL cPrgStack AS STRING
	LOCAL dwPrgNr AS DWORD
	LOCAL dwPrgStartNr AS DWORD
	*
	dwPrgStartNr := 1
	cPrgStack := ''
	dwPrgNr := dwPrgStartNr
	DO WHILE Len(AllTrim(Psz2String(ProcName(dwPrgNr)))) > 0
		IF dwPrgNr > dwPrgStartNr
			cPrgStack := cPrgStack + Space(1*(dwPrgNr-dwPrgStartNr)+1)+'--> '
		ENDIF
		cPrgStack := cPrgStack + Psz2String(ProcName(dwPrgNr))
		IF ProcLine(dwPrgNr) > 0
			cPrgStack := cPrgStack + '(' + NTrim(ProcLine(dwPrgNr)) + ')'
	  	ENDIF
		cPrgStack := cPrgStack + YOERNEWLINECHAR
		dwPrgNr := dwPrgNr + 1
	ENDDO
RETURN cPrgStack



Op 6-1-2020 om 20:41 schreef zodcomag@gmail.com:
> No, I haven't check.
> Any idea how?
> 
> Henry
> 

[toc] | [prev] | [next] | [standalone]


#12754

From"Jamal" <noooospam@example.com>
Date2020-01-06 17:25 -0500
Message-ID<qv0c49$nb7$1@news.albasani.net>
In reply to#12750
Add:

if !lGotFocus .AND. oControl:ValueChanged

    oControl:ValueChanged := false     // to prevent ErrorBox{} from being 
triggered multiple times

    // other logic that displays errorbox

endif

Jamal

wrote in message 
news:dc0a8e47-95c7-46f9-96be-6e3d5cbc89e7@googlegroups.com...

COntinue...
If I add oControl:SetFocus()    // so the customer wilol stay on this 
control until it is legal
The ErrorMessage is called twice & the focus does not realy stays on the 
control.


It should be more logic to add the code into EditFocusChange(), because the 
value is checked after it is full, when maybe the first character is not 
legall, but after adding the second character it is legel.

When adding the code to EditFocusChange(), the ErrorBox is called 3 times.

It looks to me, that exactly for that exist the FieldSpec validation.

Thanks
Henry

[toc] | [prev] | [next] | [standalone]


#12755

Fromzodcomag@gmail.com
Date2020-01-07 02:57 -0800
Message-ID<a54f2337-3945-4406-845e-266d43821476@googlegroups.com>
In reply to#12754
Jamal thanks

A part solution, bur does not work satisfactory

- if I do not change the value of the control, the customer can go on with illegal value.
- If I do change the value of the control, the customer can not see which wrong value he eneterd.

A normal behaviour will be to leave the old illegal value, not allow to go on to the next control, and tell the customer about the mistake, so he knows what the problem & can correct it.

One can be extremely complicated with EditChane or EditFocusChange, and with some tries to fell into endless loop & close the program entirely, but in my opinion, The FieldSpec class with its Min. Max, Range ... is made exactly for this.
I just do not know what should I write in "Validation", or if I right the FieldSpec class myself, how should I right the SetValidation(xValidation..) function.

Many thanks
Henry

[toc] | [prev] | [next] | [standalone]


#12756

From"Jamal" <noooospam@example.com>
Date2020-01-07 10:49 -0500
Message-ID<qv29am$iao$1@news.albasani.net>
In reply to#12755
Then your best option is to subclass the SingleLineEdit and intercept the 
keystrokes in the dispatch method.

Expand on code like this:

METHOD Dispatch(oEvent) CLASS MinMaxSLE
    DO CASE
    CASE oEvent:Message == WM_CHAR

            IF oEvent:wParam > 32
                    SUPER:Dispatch(oEvent)
                    if val(SELF:CurrentText) < YourMin .or. 
val(SELF:CurrentText) > YourMax
                        self:TextColor := Color{COLORRED}   // change 
background to indicate a bad value
                        RETURN 1L   // Ignore key
                    ELSE
                        self:ValueChanged := true
                        RETURN 1L
                    ENDIF
                ENDIF
        ENDIF
    ENDCASE

    RETURN SUPER:Dispatch(oEvent)

Search the newsgroups, I am sure you find lots of hits on using the dispatch 
method.


wrote in message 
news:a54f2337-3945-4406-845e-266d43821476@googlegroups.com...

Jamal thanks

A part solution, bur does not work satisfactory

- if I do not change the value of the control, the customer can go on with 
illegal value.
- If I do change the value of the control, the customer can not see which 
wrong value he eneterd.

A normal behaviour will be to leave the old illegal value, not allow to go 
on to the next control, and tell the customer about the mistake, so he knows 
what the problem & can correct it.

One can be extremely complicated with EditChane or EditFocusChange, and with 
some tries to fell into endless loop & close the program entirely, but in my 
opinion, The FieldSpec class with its Min. Max, Range ... is made exactly 
for this.
I just do not know what should I write in "Validation", or if I right the 
FieldSpec class myself, how should I right the SetValidation(xValidation..) 
function.

Many thanks
Henry 

[toc] | [prev] | [next] | [standalone]


#12757

FromKarl Faller <mail_withoutthat_@_drei-f_andthat_.de>
Date2020-01-07 17:28 +0100
Message-ID<6bc91fducfheklh4iol1re3brqq68b9i0c@4ax.com>
In reply to#12756
Jamal,
yes, Dispatch would probably help. 
But Henry's question is valid: 
IS Fieldspec max/min broke or simply nobody knows how to use it?


>Then your best option is to subclass the SingleLineEdit and intercept the 
>keystrokes in the dispatch method.
>
>Expand on code like this:
>
>METHOD Dispatch(oEvent) CLASS MinMaxSLE
>    DO CASE
>    CASE oEvent:Message == WM_CHAR
>
>            IF oEvent:wParam > 32
>                    SUPER:Dispatch(oEvent)
>                    if val(SELF:CurrentText) < YourMin .or. 
>val(SELF:CurrentText) > YourMax
>                        self:TextColor := Color{COLORRED}   // change 
>background to indicate a bad value
>                        RETURN 1L   // Ignore key
>                    ELSE
>                        self:ValueChanged := true
>                        RETURN 1L
>                    ENDIF
>                ENDIF
>        ENDIF
>    ENDCASE
>
>    RETURN SUPER:Dispatch(oEvent)
>
>Search the newsgroups, I am sure you find lots of hits on using the dispatch 
>method.
>
>
>wrote in message 
>news:a54f2337-3945-4406-845e-266d43821476@googlegroups.com...
>
>Jamal thanks
>
>A part solution, bur does not work satisfactory
>
>- if I do not change the value of the control, the customer can go on with 
>illegal value.
>- If I do change the value of the control, the customer can not see which 
>wrong value he eneterd.
>
>A normal behaviour will be to leave the old illegal value, not allow to go 
>on to the next control, and tell the customer about the mistake, so he knows 
>what the problem & can correct it.
>
>One can be extremely complicated with EditChane or EditFocusChange, and with 
>some tries to fell into endless loop & close the program entirely, but in my 
>opinion, The FieldSpec class with its Min. Max, Range ... is made exactly 
>for this.
>I just do not know what should I write in "Validation", or if I right the 
>FieldSpec class myself, how should I right the SetValidation(xValidation..) 
>function.
>
>Many thanks
>Henry 
Regards

Karl

[toc] | [prev] | [next] | [standalone]


#12795

FromJames Martin <james@northwoodlumber.com>
Date2020-01-18 14:10 -0500
Message-ID<qvvl6s$lk6$1@dont-email.me>
In reply to#12757
In pretty well every window I make I add a class variable lInit. At the 
beginning of PreInit I add "SELF:lInit == FALSE". At the end of PostInit 
I add "SELF:lINIT == TRUE". Then in I just have to say "IF SELF:lInit ..."

James

On 1/7/20 11:28 AM, Karl Faller wrote:
> Jamal,
> yes, Dispatch would probably help.
> But Henry's question is valid:
> IS Fieldspec max/min broke or simply nobody knows how to use it?
> 
> 
>> Then your best option is to subclass the SingleLineEdit and intercept the
>> keystrokes in the dispatch method.
>>
>> Expand on code like this:
>>
>> METHOD Dispatch(oEvent) CLASS MinMaxSLE
>>     DO CASE
>>     CASE oEvent:Message == WM_CHAR
>>
>>             IF oEvent:wParam > 32
>>                     SUPER:Dispatch(oEvent)
>>                     if val(SELF:CurrentText) < YourMin .or.
>> val(SELF:CurrentText) > YourMax
>>                         self:TextColor := Color{COLORRED}   // change
>> background to indicate a bad value
>>                         RETURN 1L   // Ignore key
>>                     ELSE
>>                         self:ValueChanged := true
>>                         RETURN 1L
>>                     ENDIF
>>                 ENDIF
>>         ENDIF
>>     ENDCASE
>>
>>     RETURN SUPER:Dispatch(oEvent)
>>
>> Search the newsgroups, I am sure you find lots of hits on using the dispatch
>> method.
>>
>>
>> wrote in message
>> news:a54f2337-3945-4406-845e-266d43821476@googlegroups.com...
>>
>> Jamal thanks
>>
>> A part solution, bur does not work satisfactory
>>
>> - if I do not change the value of the control, the customer can go on with
>> illegal value.
>> - If I do change the value of the control, the customer can not see which
>> wrong value he eneterd.
>>
>> A normal behaviour will be to leave the old illegal value, not allow to go
>> on to the next control, and tell the customer about the mistake, so he knows
>> what the problem & can correct it.
>>
>> One can be extremely complicated with EditChane or EditFocusChange, and with
>> some tries to fell into endless loop & close the program entirely, but in my
>> opinion, The FieldSpec class with its Min. Max, Range ... is made exactly
>> for this.
>> I just do not know what should I write in "Validation", or if I right the
>> FieldSpec class myself, how should I right the SetValidation(xValidation..)
>> function.
>>
>> Many thanks
>> Henry
> Regards
> 
> Karl
> 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web