Mixed language error validation messages of integer and real controls

Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

Mixed language error validation messages of integer and real controls

Unread post by Ferenc Nagy » 23 Mar 2016 12:47

Thomas,
Did you notice in our recently closed dialog that I used edit controls for entering positive integer values?
I did so because the standard minimum, maximum and digit check of integer and real control return note boxes where the labels written in native language are embedded in the prefixed English language sentences. This behavior goes back to Visual Prolog 4 where a tree contained the obligatory and optional properties of the controls.
Versions from #6 use pfc procedures. A new feature is the distinction of

Code: Select all

getInteger() <--> trygGetInteger() , getReal() <--> tryGetReal()
which differ indeterminism and behavior in the case when a letter is mixed among the digits: execution error vs. fail.
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 2388
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 23 Mar 2016 14:35

You can set the messages yourself:

Code: Select all

class integerControl : integerControl   constructors     new : (containerWindow ParentContainer).     % @short The constructor.     % @detail Creates a new integerControl object with the specified     % parent container.     % @end   constructors     new : ().     % @short The constructor.     % @detail Creates a new integerControl object without a parent container.     % @end   constants     errorMessage_illegalValue = "% must be an integer number".     errorMessage_illegalValueMandatory = "% must be specified".     errorMessage_illegalValueMinimumMaximum = "% must be between % and %".     errorMessage_illegalValueMinimum = "% must be greater than %".     errorMessage_illegalValueMaximum = "% must be less than %".     % @short These error messages are used by integer controls     % in case of an invalid content input by default. Use set..Message(..)     % predicates to customize these error messages.     % @end   predicates     setIllegalValueMessage : (string NewErrorMessage).     % @short Sets the specified error message to be used in case of illegal value.     % @detail See errorMessage_illegalValue about a format of the message.     % @end   predicates     setIllegalValueMandatoryMessage : (string NewErrorMessage).     % @short Sets the specified error message to be used in case of absent value.     % @detail See errorMessage_illegalValueMandatory about a format of the message.     % @end   predicates     setIllegalValueMinimumMaximumMessage : (string NewErrorMessage).     % @short Sets the specified error message to be used in case of     % non-belonging to the minimum-maximum range.     % @detail See errorMessage_illegalValueMinimumMaximum about a format of the message.     % @end   predicates     setIllegalValueMinimumMessage : (string NewErrorMessage).     % @short Sets the specified error message to be used in case of     % a value less than the minimum.     % @detail See errorMessage_illegalValueMinimum about a format of the message.     % @end   predicates     setIllegalValueMaximumMessage : (string NewErrorMessage).     % @short Sets the specified error message to be used in case of     % a value greater than the maximum.     % @detail See errorMessage_illegalValueMaximum about a format of the message.     % @end   end class integerControl
Regards Thomas Linder Puls
PDC

User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

Which is safest way of overriding built in classes?

Unread post by Ferenc Nagy » 24 Mar 2016 7:09

Thomas,
Thank you for the sent home-made counterpart of the class integerControl.
I do not want to modify the factory-made integerControl in Prolog Foundation Classes.
What is the safest and recommended way of making home-made versions and retaining the delivered version?
Where should I save my version if I want to use in future programs? How shall I refer them form the *.pack and *.ph files?
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 2388
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 24 Mar 2016 12:31

I have copied the code above directly from the Visual Prolog 7.5 release.
Regards Thomas Linder Puls
PDC

User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

Unread post by Ferenc Nagy » 24 Mar 2016 14:06

Thank you, Thomas. Now I understand how

Code: Select all

setIllegalValueMandatoryMessage
and the other procedures work. They give new values to the facts initiated by standard mesage format strings.

Code: Select all

constants     errorMessage_illegalValueMandatory = "% must be specified".   class facts     errMsg_illegalValueMandatory_fact : string := errorMessage_illegalValueMandatory.     clauses     setIllegalValueMessage(ErrorMessage) :-         errMsg_illegalValue_fact := ErrorMessage.   clauses     setIllegalValueMandatoryMessage(ErrorMessage) :-         errMsg_illegalValueMandatory_fact := ErrorMessage.
The above fact is used when the control contains empty string.
TIA, Regards,
Frank Nagy

User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

Unread post by Ferenc Nagy » 1 Apr 2016 7:11

See my post among Tips and Samples http://discuss.visual-prolog.com/viewtopic.php?t=15512 .
TIA, Regards,
Frank Nagy

Post Reply