Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #1212 > unrolled thread
| Started by | Krystian <softb@softb.pl> |
|---|---|
| First post | 2011-05-30 02:00 -0700 |
| Last post | 2011-05-30 12:20 -0400 |
| Articles | 12 — 7 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Field validation Krystian <softb@softb.pl> - 2011-05-30 02:00 -0700
Re: Field validation D.J.W. van Kooten <public@ic2remove.this.com> - 2011-05-30 13:31 +0200
Re: Field validation Krystian <softb@softb.pl> - 2011-05-30 15:09 -0700
Re: Field validation "richard.townsendrose" <richard.townsendrose@gmail.com> - 2011-05-31 01:05 -0700
Re: Field validation D.J.W. van Kooten <public@ic2remove.this.com> - 2011-05-31 12:00 +0200
Re: Field validation Karl Faller <k.faller_withoutthat_@onlinehome.de> - 2011-05-31 15:52 +0200
Re: Field validation D.J.W. van Kooten <public@ic2remove.this.com> - 2011-06-01 00:20 +0200
Re: Field validation Karl Faller <k.faller_withoutthat_@onlinehome.de> - 2011-06-01 09:23 +0200
Re: Field validation "richard.townsendrose" <richard.townsendrose@gmail.com> - 2011-06-01 01:16 -0700
Re: Field validation wolverine <wolverine4277@hotmail.com> - 2011-05-30 05:08 -0700
Re: Field validation "Willie Moore" <williem@wmconsulting.com> - 2011-05-30 09:37 -0500
Re: Field validation "Roger Lawton" <nsproger@nspsomax.com> - 2011-05-30 12:20 -0400
| From | Krystian <softb@softb.pl> |
|---|---|
| Date | 2011-05-30 02:00 -0700 |
| Subject | Field validation |
| Message-ID | <4aeaf2f0-fa83-4d6e-b3ee-f6fc76cf0443@a26g2000vbo.googlegroups.com> |
Hi,
I would like to "implement" standard clipper Valid statement for a
SingleLineEdit in a DataWindow
This is a piece of code from PostInit
oSFS := StringFS{HyperLabel{#nr_pesel}}
oHLVal := HyperLabel{#nr_pesel, , 'Błędny numer PESEL'}
oSFS:setValidation({|x| spr_pese(x)}, oHLVal)
SELF:oDCNr_pesel:FieldSpec := oSFS
function spr_pesel returns logic value.
What is wrong in it, what I miss to set, because the control does not
enter to function spr_pesel()
Any help is welcome, thanks a lot
But please "IN CAPITAL LETTERS" - I am on the beginning of my
adventure with CAVO
Krystian
[toc] | [next] | [standalone]
| From | D.J.W. van Kooten <public@ic2remove.this.com> |
|---|---|
| Date | 2011-05-30 13:31 +0200 |
| Message-ID | <siv6u61m4p2060m3p0opgqkp6kbh1oj5ho@4ax.com> |
| In reply to | #1212 |
On Mon, 30 May 2011 02:00:31 -0700 (PDT), Krystian <softb@softb.pl> wrote: Hello Krystian, >What is wrong in it, what I miss to set, because the control does not >enter to function spr_pesel() > I never use this SetValidation method so I am not sure why it doesn't work. You could try a simple validation string instead. The codeblock calling a function should work too, maybe it is not visible in the library where your Fieldspecs are? I always use EditFocusChange for these kind of validations. E.g. IF oControl:namesym=#XXX.AND. lGotFocus Dick
[toc] | [prev] | [next] | [standalone]
| From | Krystian <softb@softb.pl> |
|---|---|
| Date | 2011-05-30 15:09 -0700 |
| Message-ID | <9917998b-4953-41b5-8ae8-ca66e45d8acd@hd10g2000vbb.googlegroups.com> |
| In reply to | #1214 |
On May 30, 1:31 pm, D.J.W. van Kooten <pub...@ic2remove.this.com> wrote: > On Mon, 30 May 2011 02:00:31 -0700 (PDT), Krystian <so...@softb.pl> > wrote: > > Hello Krystian, > > >What is wrong in it, what I miss to set, because the control does not > >enter to function spr_pesel() > > I never use this SetValidation method so I am not sure why it doesn't > work. You could try a simple validation string instead. The codeblock > calling a function should work too, maybe it is not visible in the > library where your Fieldspecs are? > > I always use EditFocusChange for these kind of validations. E.g. > > IF oControl:namesym=#XXX.AND. lGotFocus > > Dick Hallo Dick & Co, Thank you for attention and time for my problem. But it still does not work. 1/ I can not put the validation code into EditFocusChange - it hangs the whole application. 2/ the function is "very simple" and defined in the same module : FUNCTION spr_pesel( pese ) LOCAL test AS LOGIC test := false RETURN test 3/ CAVO v.2.8 SP1 4/ the function is visible for the linker; it works OK with Accept button. I have no idea, what is wrong. I go sleep, maybe tomorrow ... Thanks and good night, bye Krystian
[toc] | [prev] | [next] | [standalone]
| From | "richard.townsendrose" <richard.townsendrose@gmail.com> |
|---|---|
| Date | 2011-05-31 01:05 -0700 |
| Message-ID | <6e80a0c6-20bc-45aa-8b30-5c3dffcf1976@h7g2000yqa.googlegroups.com> |
| In reply to | #1219 |
Krystian
below is the system which we use.
OBJECTS - VO is NOT clipper it is VO .... persevere - it will become
very easy ...
What we have used for many years is a validation system based on code
written in VO 1 days
So to start ...
Window. When the focus of the control being edited is lost - viz focus
goes somewhere else then the window:editfocuschange() method is called
by vo.
so subclass your window class and add:
CLASS V4_DataWindow INHERIT V4_ExtDataWindow
PROTECT lDirty AS LOGIC
PROTECT aTrigRefText AS ARRAY // array of controls that
trigger RefreshText in Editfocuschange
PROTECT aTrigDirty AS ARRAY // array of control that trigger
dirty state in editchange
PROTECT AllTrigDirty AS LOGIC // if true allcontrols trigges
dirty state
// PROTECT lDoNotify AS LOGIC
EXPORT ActivateEditChange AS LOGIC // Activete the dirty handling
EXPORT lValidationOn AS LOGIC // to validate from
EditFocusChange Method instead Notify
//PROTECT sUserAction AS SYMBOL //#ADD #EDIT #SIMILAR
INSTANCE sUserAction AS SYMBOL //#ADD #EDIT #SIMILAR // rgtr 150802
PROTECT aSYMBOLVars AS ARRAY //TabVarGet TabVarPut
PROTECT aFormatVars AS ARRAY
PROTECT aValueVars AS ARRAY
PROTECT oDocument AS Document // ARG121999
PROTECT cViewer AS STRING
PROTECT aViewers AS ARRAY // ARG121999
PROTECT oViewButton AS PushButton
//PROTECT oMaster AS Document // rgtr 140507
//PROTECT oViewMaster AS PushButton // rgtr 291106
DECLARE METHOD TABVarGet
you can see we have handling for "Save" and "Cancel" using the dirty
concept. and which fields can set it.
we have document viewing
we have a "TabVar" concept for variables common to several pages on a
tab
and using field spec we have a validation system. this starts it.
we have two things: validation and a call to "RefreshText()" method.
so this can set the phone no of a person when they are selected etc
etc.
METHOD EditFocusChange(oEditFocusChangeEvent) CLASS V4_DataWindow
LOCAL oControl AS Control
LOCAL lGotFocus AS LOGIC
oControl := IIF(oEditFocusChangeEvent == NULL_OBJECT, NULL_OBJECT,
oEditFocusChangeEvent:Control)
lGotFocus := IIF(oEditFocusChangeEvent == NULL_OBJECT, FALSE,
oEditFocusChangeEvent:GotFocus)
//Put your changes here
IF !lGotFocus .AND.
AScan(SELF:aTrigRefText,oControl:NameSym)>0 .AND.
oControl:ValueChanged
SELF:RefreshText(oControl:NameSym)
ENDIF
SUPER:EditFocusChange(oEditFocusChangeEvent)
IF !lGotFocus .AND. SELF:lValidationOn //if lValidation
is TRUE DO Validation
SELF:ControlValidation(oControl)
ENDIF
RETURN NIL
so here are the methods of the window needed:
METHOD CleanDirtyControls() CLASS V4_ExtDataWindow
LOCAL wLen AS DWORD // rgtr 080105 was word
LOCAL wX AS WORD
LOCAL oControl AS OBJECT
wLen := ALen(SELF:Controls)
FOR wX := 1 TO wLen
oControl:=SELF:Controls[wX]
IF oControl:FieldSpec <> NULL_OBJECT .AND.
IsMethod(oControl:FieldSpec,#Valid)
oControl:Background := oBrushNormal
ENDIF
NEXT
RETURN SELF
ACCESS Controls CLASS V4_ExtDataWindow
RETURN SELF:aControls
METHOD ControlValidation(oControl) CLASS V4_ExtDataWindow
IF oControl:FieldSpec <> NULL_OBJECT .AND.
IsMethod(oControl:FieldSpec,#Valid)
SELF:cWarningText := ''
IF !SELF:IsControlValid(oControl)
oControl:Background := oBrushYellow
SELF:AlertMessage('Error: '+SELF:cErrorText,MESSAGECONTROL)
ELSE
oControl:Background := oBrushNormal
IF !Empty(SELF:cWarningText)
SELF:AlertMessage('Warning: '+SELF:cWarningText,MESSAGECONTROL)
SELF:cWarningText := ''
ENDIF
ENDIF
ENDIF
RETURN TRUE
METHOD IsControlValid(oControl) CLASS V4_ExtDataWindow
LOCAL lOk := TRUE AS LOGIC
IF !IsAccess(oControl,#IsEnabled) .OR. oControl:IsEnabled
SELF:cErrorText := ''
IF oControl:FieldSpec <> NULL_OBJECT .AND.
IsMethod(oControl:FieldSpec,#Valid)
lOk := oControl:FieldSpec:Valid(oControl)
IF lOk
IF oControl:FieldSpec:Validation <> NIL
lOk := Eval(oControl:FieldSpec:Validation,oControl:Value)
IF !lOk
SELF:cErrorText := oControl:FieldSpec:Status
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
RETURN lOk
METHOD IsRecordValid() CLASS V4_ExtDataWindow
LOCAL wLen AS DWORD // rgtr 080105 was word
LOCAL wX AS DWORD
LOCAL lOk AS LOGIC
LOCAL oControl AS OBJECT
LOCAL nFirstControlDirty AS DWORD
lOk := TRUE
nFirstControlDirty:=0
SELF:cErrorText := ''
wLen := ALen(SELF:Controls)
FOR wX := 1 TO wLen
oControl := SELF:Controls[wX]
IF oControl:FieldSpec <> NULL_OBJECT .AND.
IsMethod(oControl:FieldSpec,#Valid)
IF !SELF:IsControlValid(oControl)
IF IsControlEnabled(oControl) //CAL 070602 to keep disabled
controls gray
oControl:Background := oBrushYellow
ENDIF
lOk := FALSE
IF nFirstControlDirty=0
SELF:AlertMessage('Error: '+SELF:cErrorText,MESSAGECONTROL)
nFirstControlDirty:=wX
ENDIF
ELSE
IF IsControlEnabled(oControl) //CAL 070602 to keep disabled
controls gray
oControl:Background := oBrushNormal
ENDIF
ENDIF
ENDIF
NEXT
IF nFirstControlDirty>0
SELF:Controls[nFirstControlDirty]:SetFocus()
ENDIF
RETURN lOk
and here is the field spec stuff
CLASS MyFIELDSPEC INHERIT FieldSpec
PROTECT aValidations AS ARRAY
PROTECT auArgument AS ARRAY
PROTECT lForceUpper AS LOGIC
METHOD Init(oHyperLabel,uType,nLength,nDecimals) CLASS MyFIELDSPEC
SUPER:Init(oHyperLabel,uType,nLength,nDecimals)
aValidations:={}
auArgument:={}
RETURN SELF // rgtr 131003
CLASS F256Char INHERIT MyFIELDSPEC
METHOD Init() CLASS F256Char
SUPER:Init(HyperLabel{"F256Char","","",""},"C",256,0)
RETURN SELF // rgtr 190507
and here is some window initialisation stuff from a postinit.
METHOD PostInit(oWindow,iCtlID,oServer,uExtra) CLASS NamesEdit
SELF:Use(SELF:Owner:asNM)
SELF:UserAction:=#EDIT
SELF:oDCTyp1:fillUsing(SysObject():GetCat(NAME_POSITION):ListBoxArray)
SELF:oDCTyp2:fillUsing(SysObject():GetCat(NAME_TYPE):ListBoxArray)
SELF:oDCInUse:Disable()
SELF:oCCGetRef:Hide()
// Set Validation (UserAction ASSIGN has new validation rules)
SELF:oDCNameX:FieldSpec:AppendValidation({|oCtrl|
CheckTitleOk(oCtrl)})
SELF:oDCContact:FieldSpec:AppendValidation({|oCtrl|
CheckTitleOk(oCtrl)})
SELF:oDCTyp1:FieldSpec:AppendValidation({|
oCtrl,cCatDescription,cRequired|
CheckCatCodeExists(oCtrl,cCatDescription,cRequired)},NAME_POSITION,"NO")
SELF:oDCTyp2:FieldSpec:AppendValidation({|
oCtrl,cCatDescription,cRequired|
CheckCatCodeExists(oCtrl,cCatDescription,cRequired)},NAME_TYPE,"NO")
SELF:oDCEmail:FieldSpec:AppendValidation({|oCtrl|CheckEMailOk(oCtrl,
FALSE)})
SELF:oDCHANDLER:FieldSpec:AppendValidation({|oCtrl|
CheckNameExists(oCtrl, FALSE)}) // rgtr 131109 per mike !
SELF:oDCSUBSET:FieldSpec:AppendValidation({|oCtrl|
CheckNameExists(oCtrl, FALSE)})
SELF:AllTrigDirty:=TRUE
SELF:lValidationOn:=TRUE
SELF:ActivateEditChange:=TRUE
SELF:aTrigRefText:={#NAMEX, #NAMEREF}
SELF:SetScr()
RETURN NIL
METHOD RefreshText(symName) CLASS NamesEdit
IF symName == #NAMEREF .OR. symName == #NAMEX
IF sUserAction==#NEW // .AND. ! SysObject():GetParam(NameRefType) ==
'A'
SELF:oCCGetRef:Show()
IF Len(StrTran(SELF:oDCNAMEX:Value,' ','')) > 3 .AND.
Empty(SELF:oDCNameREf:VALUE)
SELF:oCCGetRef:Enable()
ELSE
SELF:oCCGetRef:Disable()
ENDIF
ELSE
SELF:oCCGetRef:Hide()
ENDIF
ENDIF
IF symName == #EMAIL
ENDIF
RETURN NIL // rgtr 190507
if you would like the whole lot ... email me ...
but what i suggest is that you start very slowly and build your self a
library of what you need
we also have bbrowser modifications so that you can search in a browse
and display messages. but it has taken many people and many years to
get to this.
Dr Paolo Kalc (Calzi) is the man who assembled what we have now. and
all i can say is that it is very fast, very flexible, and works.
you can download a free trial of tdoc to see what can be done. email
me for details
you can see our manual www.tdocplus.co.uk/tdoc_manual - there are a
few links which are in error - as the new server is linux and case
sensitive - whereas we used not to be case sensitive. ouch ...
richard
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <public@ic2remove.this.com> |
|---|---|
| Date | 2011-05-31 12:00 +0200 |
| Message-ID | <6se9u6tj8jrum0vag7vkhifeu1sv60m4q9@4ax.com> |
| In reply to | #1219 |
On Mon, 30 May 2011 15:09:28 -0700 (PDT), Krystian <softb@softb.pl> wrote: >On May 30, 1:31 pm, D.J.W. van Kooten <pub...@ic2remove.this.com> >wrote: Hello Krystian, > >1/ I can not put the validation code into EditFocusChange - it hangs >the whole application. That happens when you ommit the Gotfocus info. That makes sure that it is only checked when you either enter or leave the control, not that any change you make while you ar IN the control again call your code in EditFocusChange indefinitely, so your application hangs. Dick
[toc] | [prev] | [next] | [standalone]
| From | Karl Faller <k.faller_withoutthat_@onlinehome.de> |
|---|---|
| Date | 2011-05-31 15:52 +0200 |
| Message-ID | <4ks9u6t5lr6tm66o2re205aqjss8tlt24f@4ax.com> |
| In reply to | #1221 |
Dick, >not that >any change you make while you ar IN the control IMHO that shouldn't happen - you are in EditFOCUSChange, not in EditChange... Karl
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <public@ic2remove.this.com> |
|---|---|
| Date | 2011-06-01 00:20 +0200 |
| Message-ID | <r9qau650vuj7rkm71evq8kr8u84umlio02@4ax.com> |
| In reply to | #1223 |
On Tue, 31 May 2011 15:52:42 +0200, Karl Faller <k.faller_withoutthat_@onlinehome.de> wrote: Hello Karl, >IMHO that shouldn't happen - you are in EditFOCUSChange, not in >EditChange... > It shouldn't indeed but try to add some code to the Editfocuschange without that lGotfocus condition and you get exactly what Krystian describes: he program hangs due to indefinite calls. Dick
[toc] | [prev] | [next] | [standalone]
| From | Karl Faller <k.faller_withoutthat_@onlinehome.de> |
|---|---|
| Date | 2011-06-01 09:23 +0200 |
| Message-ID | <jppbu6ptsij7qge800gjr1fvn0ts4rovq3@4ax.com> |
| In reply to | #1227 |
Dick, make a BasicDlg from Sample. Add some sles Add a module: CLASS dlg_EFC INHERIT MainDialog METHOD EditFocusChange(oE) CLASS dlg_EFC SELF:caption += "HU" SELF:test() RETURN SUPER:EditFocusChange(oE) METHOD test() CLASS dlg_EFC RETURN "X" change Start to use the inherited dlg. I see my caption change whenever i enter or one of the sles, but NOT when i type anything into them. Just to make sure i didn't miss something, i even repeated the above for a datawindow, whith the same result... So? Karl > >>IMHO that shouldn't happen - you are in EditFOCUSChange, not in >>EditChange... >> >It shouldn't indeed but try to add some code to the Editfocuschange >without that lGotfocus condition and you get exactly what Krystian >describes: he program hangs due to indefinite calls. > >Dick
[toc] | [prev] | [next] | [standalone]
| From | "richard.townsendrose" <richard.townsendrose@gmail.com> |
|---|---|
| Date | 2011-06-01 01:16 -0700 |
| Message-ID | <4245efa0-7b01-4024-8f45-792a48bb84f9@c41g2000yqm.googlegroups.com> |
| In reply to | #1229 |
Guys
EditFocusChange is what it says.
EditChange is what it says.
We use a generic EditChange to run our "dirty" system - including
making other tabs not selectable
We use EditFocusChange to do two things
a) to call "RefreshText(symName)" for screen updating as the example
by Karl
b) to call the field validation system which calls a function with
parameters. other controls, data tables can be passed for date
comparisons etc
regards
richard
FUNCTION CheckDatePairOk(oCtrl,sleSecondDate,lIf2ndLater)
LOCAL nDate1 AS LONGINT
LOCAL nDate2 AS LONGINT
LOCAL lResult:=TRUE AS LOGIC
nDate1:=LONG(_CAST, oCtrl:Value)
ndate2:=LONG(_CAST, sleSecondDate:Value)
IF Empty(oCTRL:Value) .OR. Empty(sleSecondDate:Value) // nothing to
check
lResult:=TRUE
ELSE
IF lIf2ndLater // then date1 should be less or equal to date2
IF nDate1 > nDate2
lResult:=FALSE
ENDIF
ELSE // else date2 should be less or equal to date1
IF nDate2 > nDate1
lResult:=FALSE
ENDIF
ENDIF
ENDIF
IF lResult
RETURN NULL_OBJECT
ELSE
RETURN
HyperLabel{#Error,LoadResString('Error',IDG_ERROR,nPLH),LoadResString('Date
Range reversed - not valid',IDK_DATERANGEREVERSEDNOTVALID,nPLH)}
ENDIF
RETURN NULL_OBJECT
[toc] | [prev] | [next] | [standalone]
| From | wolverine <wolverine4277@hotmail.com> |
|---|---|
| Date | 2011-05-30 05:08 -0700 |
| Message-ID | <6d55607b-8920-451f-9a34-c22805298075@y12g2000yqh.googlegroups.com> |
| In reply to | #1212 |
If i'm not wrong the function in a codeblock cannot be strong typed.
Can be that the problem?
Sebastián
On 30 mayo, 06:00, Krystian <so...@softb.pl> wrote:
> Hi,
>
> I would like to "implement" standard clipper Valid statement for a
> SingleLineEdit in a DataWindow
> This is a piece of code from PostInit
>
> oSFS := StringFS{HyperLabel{#nr_pesel}}
> oHLVal := HyperLabel{#nr_pesel, , 'Błędny numer PESEL'}
>
> oSFS:setValidation({|x| spr_pese(x)}, oHLVal)
>
> SELF:oDCNr_pesel:FieldSpec := oSFS
>
> function spr_pesel returns logic value.
>
> What is wrong in it, what I miss to set, because the control does not
> enter to function spr_pesel()
>
> Any help is welcome, thanks a lot
> But please "IN CAPITAL LETTERS" - I am on the beginning of my
> adventure with CAVO
> Krystian
[toc] | [prev] | [next] | [standalone]
| From | "Willie Moore" <williem@wmconsulting.com> |
|---|---|
| Date | 2011-05-30 09:37 -0500 |
| Message-ID | <is0a2b$4un$1@speranza.aioe.org> |
| In reply to | #1212 |
Krystian,
What version of VO are you using? Various parts of the GUI classes have
changed with the different releases so it is very difficult to give an
answer without knowing the version.
Regards,
Willie
"Krystian" wrote in message
news:4aeaf2f0-fa83-4d6e-b3ee-f6fc76cf0443@a26g2000vbo.googlegroups.com...
Hi,
I would like to "implement" standard clipper Valid statement for a
SingleLineEdit in a DataWindow
This is a piece of code from PostInit
oSFS := StringFS{HyperLabel{#nr_pesel}}
oHLVal := HyperLabel{#nr_pesel, , 'Błędny numer PESEL'}
oSFS:setValidation({|x| spr_pese(x)}, oHLVal)
SELF:oDCNr_pesel:FieldSpec := oSFS
function spr_pesel returns logic value.
What is wrong in it, what I miss to set, because the control does not
enter to function spr_pesel()
Any help is welcome, thanks a lot
But please "IN CAPITAL LETTERS" - I am on the beginning of my
adventure with CAVO
Krystian
[toc] | [prev] | [next] | [standalone]
| From | "Roger Lawton" <nsproger@nspsomax.com> |
|---|---|
| Date | 2011-05-30 12:20 -0400 |
| Message-ID | <is0g3k$lq1$1@speranza.aioe.org> |
| In reply to | #1212 |
Krystian:
I use the setValidation method in my code and it works fine (VO28 sp2).
One thing to check is if your spr_pese(e) function is called anywhere else.
If not then it may not be loaded by the linker. I have had a few instances
where functions that are only executed from code blocks must be "phantom"
called so the linker will link them into the exe/dll.
Just a thought.
Roger
"Krystian" <softb@softb.pl> wrote in message
news:4aeaf2f0-fa83-4d6e-b3ee-f6fc76cf0443@a26g2000vbo.googlegroups.com...
Hi,
I would like to "implement" standard clipper Valid statement for a
SingleLineEdit in a DataWindow
This is a piece of code from PostInit
oSFS := StringFS{HyperLabel{#nr_pesel}}
oHLVal := HyperLabel{#nr_pesel, , 'Błędny numer PESEL'}
oSFS:setValidation({|x| spr_pese(x)}, oHLVal)
SELF:oDCNr_pesel:FieldSpec := oSFS
function spr_pesel returns logic value.
What is wrong in it, what I miss to set, because the control does not
enter to function spr_pesel()
Any help is welcome, thanks a lot
But please "IN CAPITAL LETTERS" - I am on the beginning of my
adventure with CAVO
Krystian
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web