Can anyone get a #Validate to work with a #Prompt Option on an #Extension ,Application(ExtensionProc) ?
C11
TIA
Can anyone get a #Validate to work with a #Prompt Option on an #Extension ,Application(ExtensionProc) ?
C11
TIA
Without seeing the template code it’s a bit hard to diagnose. I use VALIDATE all over the place, the trick is knowing when it will be processed.
Its just not working, when selecting a radio option or when the extension is saved.
As long as it follows the #PROMPT that’s being validated it should be fine. Again, a small example might help.
Guess what, I got a new error message.
(IS_DemoForLee.TPL 15,1) Error: RADIO and ENDOPTION are only valid in an OPTION prompt File=C:\Clarion11\accessory\template\win\IS_DemoForLee.TPL, Line=15 Column=1
This was when I had the #Validates under each #Prompt Radio.
Anyway here’s the demo.
#TEMPLATE(IS_DemoForLee,'Radio button #Validate Demo For Lee'),FAMILY('ABC','CW20')
#System
#Declare(%ErrorMsgCnt,Long)
#Set(%ErrorMsgCnt,0)
#Extension(IS_DemoForLeeGlobal,'Radio button #Validate Demo For Lee - Global')
#Sheet,HScroll
#Tab('0&1')
#Display('')
#Prompt('Test Radio Button Validate',Option),%ISValidateRadioButton,Default('Radio1')
#Validate(%grpErrMsg(%True,'Test The Radio Button Validate',%ISValidateRadioButton),'Show This Message IF Returned False - Radio Button - Option')
#Prompt('Radio1',Radio),Value('Radio1')
#Prompt('Radio2',Radio),Value('Radio2')
#Display('')
#Prompt('CheckBox Example',Check),%ISValidateCheckBox,At(10),Default(%True)
#Validate(%grpErrMsg(%True,'Test The Check Box Validate1',%ISValidateCheckBox),'Show This Message IF Returned False - Check Box1')
#Validate(%grpErrMsg(%True,'Test The Check Box Validate2',%ISValidateCheckBox),'Show This Message IF Returned False - Check Box2') #! Yes #Validates can be stacked
#Validate(%grpErrMsg(%True,'Test The Check Box Validate3',%ISValidateCheckBox),'Show This Message IF Returned False - Check Box2') #! Yes #Validates can be stacked
#EndTab
#Endsheet
#!Validate(%grpErrMsg(%True,'Test The Radio Button Validate - Radio1),'Show This Message IF Returned False - Radio Button - Radio1')
#!Validate(%grpErrMsg(%True,'Test The Radio Button Validate - Radio2'),'Show This Message IF Returned False - Radio Button - Radio2')
#Group(%grpErrMsg,%pShowMsg,%pMsg,%pV1='',%pV2='',%pV3='',%pV4='',%pV5='',%pV6='',%pV7='',%pV8='',%pV9='',%pV10='')
#IF(%pShowMsg = %True)
#Set(%ErrorMsgCnt,%ErrorMsgCnt + 1)
#Declare(%DateString)
#Declare(%TimeString)
#Set(%DateString,Format(Today(),@d17b))
#Set(%TimeString,Format(Clock(),@T8b))
#Error(Format(%ErrorMsgCnt,@n09) &';'& %DateString &';'& %TimeString &';'& %pMsg &';'& %pV1 &';'& %pV2 &';'& %pV3 &';'& %pV4 &';'& %pV5 &';'& %pV6 &';'& %pV7 &';'& %pV8 &';'& %pV9 &';'& %pV10 )
#! The above shows up in the Error pad
#EndIF
#Return %True
Taking a stab here but #VALIDATE should follow the last radio of the option.
You might want to compare %ISValidateRadioButton to an actual value since it will always have a value.
error always gets posted to the error pad.
Doesnt make any difference. It works in C6 though.
Yeah I’m using the error in a group as a sort of debugview output for the templates, thats what the #group does.
This works in C10…
#PROMPT('Maximum width of CSV file line',@N6),%GWBMaxFileWidth,DEFAULT(1000)
#VALIDATE((%GWBMaxFileWidth > 1000) AND (%GWBMaxFileWidth < 2000),'Value must be between 100 and 200')
The validation happens when the OK button is pressed on the template prompts page. I’m not sure what it does differently in C6?
Maybe what you are looking for is …
WHENACCEPTED Specifies an expression to execute when the #PROMPT posts an Accepted event (the programmer has entered or chosen data).
…which, from memory, happens immediately a #PROMPT is accepted.
Yes, I could put the %grpErrMsg call in a WhenAccepted, as a work around*, but I cant then stack the #Validates which is important.
*The workaround would need an extra #Group that would then #Call all the %grps that would have been called by the stacked #validates.
So normally a #Prompt triggers the #validate if the value has changed and again when the OK button is clicked to exit and save the #Extension, but in this case the Option/Radio control is not triggering the #validate in either situation.
Just tried it with a CHECK and #VALIDATE is working as defined in the help…
" The #VALIDATE statement validates the data entered into the #PROMPT field immediately preceding the #VALIDATE. The expression is evaluated when the OK button is pressed on the Procedure Properties window. If the expression is false, the message is displayed to the programmer in a message box"
I got caught by the “if the expression is false” !
Yeah its only the Option (and thus Radio’s) thats not working with #Validate.
And you can do some fancy stuff with the messages as well, like …
#Validate(%False,'My Message' & %grpCallAnotherGroup(%WithParmeters1, %AndTwo) )
Let me ask one more question for myself
. What, exactly, are you trying to validate about the option choices?
#VALIDATE is generally, at least from my use, to check the value entered against constraints. In the case of an OPTION there are a fixed set of values and no ability to pick anything else, so what are validating?
Call me puzzled!!! ![]()
I use #Validate like a TakeAccepted embed. ![]()
A better attribute for that might be WhenAccepted.
So you’re not actually trying to validate the choice, just note that one has been made? That would be along the lines of WHENACCEPTED().
I am and I’m not. Option/Radios, cant be validated like Check, because the answers are built in, making it impossible to have the wrong result, other than user error.
Sure WhenAccepted is also a valid option, but I just wanted to check it wasnt me doing something wrong with the validate.
Since both are known values #VALIDATE may never have been designed for them. I know I’ve never used it on either prompt type.
I have used WHENACCEPTED() as well as #PREPARE() to check and access values from both, just never #VALIDATE.
Its not listed as an exception on the help doc page for #Validate.