Paradox Community

Items in pnews.paradox-programming

Subject:Re: Move to to Library
Date:Tue, 18 Dec 2018 04:44:59 -0500
From:"Kevin Baker" <shcsbaker@gmail.com>
Newsgroups:pnews.paradox-programming
Kevin -

I'm using custom error handling and I write all errors to a error.log.  When 
I began to review these log from different users I noticed a lot of errors 
with invalid character.  This is an attempt to prevent the error from being 
disabled to the user and from being written to the log file.  With the error 
shrinking keys today, I fear some of my users are having trouble pressing a 
single key (fat fingers, small keys).


"Kevin Zawicki"  wrote in message 
news:5c133842$1@pnews.thedbcommunity.com...



But the picture prevents "errors".
What errors would you trap for?


"Kevin Baker" <shcsbaker@gmail.com> wrote:
>yes, there is already a picture on the field.  I added code to my custom

>error handling to write errors to a log file, and if the user presses a

>letter, it would result in an invalid key error, so this was my workaround.

>Let the picture handle the format if the users types something not allowed

>then just do nothing.  Not sure if this is the best fix, but seems to be

>working pretty good so far.
>
>"Kevin Zawicki"  wrote in message
>news:5c0d9e48$1@pnews.thedbcommunity.com...
>
>
>OK, so you are trapping for "valid" keys?
>
>You could also use a picture?
>
>
>"Kevin Baker" <shcsbaker@gmail.com> wrote:
>>Thanks Kevin, The Return and Tab are used to move to the next field
>>
>>Thanks again,
>>Kevin
>>
>>"Kevin Zawicki"  wrote in message
>>news:5c0b516e$1@pnews.thedbcommunity.com...
>>
>>
>>Something like this
>>
>>var
>>a array[] string
>>endvar
>>
>>x = "z"
>>
>>a.addLast("0")
>>a.addLast("1")
>>a.addLast("2")
>>a.addLast("3")
>>a.addLast("4")
>>a.addLast("5")
>>a.addLast("6")
>>a.addLast("7")
>>a.addLast("8")
>>a.addLast("9")
>>a.addLast("VK_RETURN")
>>a.addLast("VK_TAB")
>>a.addLast("(")
>>a.addLast(")")
>>
>>return a.contains(x)
>>
>>
>>many variations
>>could also do a string and do a match for the characters
>>not sure why trapping for VK_RETURN or VK_TAB.
>>
>>
>>
>>
>>"Kevin Baker" <shcsbaker@gmail.com> wrote:
>>>Kevin -
>>>Works Great!  I'm curious about how to put these into an array.  I'm
>>>always
>>
>>>looking to streamline any code I can.
>>>
>>>Thanks
>>>Kevin
>>>
>>>"Kevin Zawicki"  wrote in message
>>>news:5c02bee7$1@pnews.thedbcommunity.com...
>>>
>>>
>>>You cannot disable default in a library at that point the library is the
>>
>>>scope.
>>>
>>>You need to return a logical and act on that back in the form.
>>>
>>>Something like this:
>>>
>>>method keyChar(var eventInfo KeyEvent)
>>>
>>>if lib.ckPhone(eventInfo.char()) = false then
>>>  disabledefault
>>>endif
>>>
>>>
>>>endMethod
>>>
>>>=====================================================
>>>
>>>And this is the code in the library
>>>=====================================================
>>>method ckPhone(x string) logical
>>>var
>>>  l logical
>>>endvar
>>>
>>>l = true
>>>
>>>switch
>>>   case x >="0" and x <="9"    :
>>>   case x = "-" or x = " "         :
>>>   case x = "(" or x = ")"        :
>>>   case x = "VK_RETURN"            :
>>>   case x = "VK_TAB"                :
>>>   otherwise                        : l = false
>>>endSwitch
>>>
>>>return l
>>>
>>>I would also put these keys to trap in an array and test the array.
>>>
>>>You can streamline this code quit a bit.
>>>
>>>
>>>
>>>------------------------
>>>
>>>
>>>"Kevin Baker" <shcsbaker@gmail.com> wrote:
>>>>Hi Everyone,
>>>>
>>>>In a phone field I have the following code:
>>>>
>>>>=====================================================
>>>>method keyChar(var eventInfo KeyEvent)
>>>>
>>>>var
>>>>   curChar string
>>>>endvar
>>>>
>>>>curChar = eventInfo.char()
>>>>
>>>>switch
>>>>   case curChar >="0" and curChar <="9"      :
>>>>   case curChar = "-" or curChar = " "             :
>>>>   case curChar = "(" or curChar = ")"         :
>>>>   case curChar = "VK_RETURN"                 :
>>>>   case curChar = "VK_TAB"                        :
>>>>   otherwise                                                :
>>>> disableDefault
>>>
>>>>return
>>>>endSwitch
>>>>endMethod
>>>>=====================================================
>>>>
>>>>This works PERFECT, however, I'd like to move this code to a existing
>>>>library (and a library I already open on init or the form).  Here's the
>>>
>>>>updated code on the form:
>>>>
>>>>=====================================================
>>>>method keyChar(var eventInfo KeyEvent)
>>>>
>>>>lib.ckPhone(eventInfo.char())
>>>>endMethod
>>>>=====================================================
>>>>
>>>>And this is the code in the library
>>>>=====================================================
>>>>method ckPhone(x string)
>>>>
>>>>switch
>>>>   case x >="0" and x <="9"    :
>>>>   case x = "-" or x = " "         :
>>>>   case x = "(" or x = ")"        :
>>>>   case x = "VK_RETURN"            :
>>>>   case x = "VK_TAB"                :
>>>>   otherwise                        : disableDefault return
>>>>endSwitch
>>>>=====================================================
>>>>
>>>>I'm getting a error on the disableDefault (message in status bar reads:
>>>
>>>>Error: Cannot use EVENT statement in this context)
>>>>
>>>>Any ideals of how to work around this?  In a nutshell, when the code
is
>>>on
>>>>the field if the user presses any key not listed, nothing happens, no
>>>>beeps,
>>>
>>>>no error messages, which is what I need.  I'm just trying to move this
>>code
>>>
>>>>into a library so I can reuse on other forms.
>>>>
>>>>Thanks,
>>>>Kevin
>>>>
>>>
>>
> 


Copyright © 2004 thedbcommunity.com