O7 vs. O$: Input Mask Issue

Terence J. Young, D.C. terry.young at mail.mhcdc.org
Wed May 21 14:38:24 EDT 2008


Hi David,

Bug or Feature, I have experienced a similar problem in that we use a 
masked text field to allow entry of SSN's that are stored in our tables 
as an integer.  I documented my workaraound as follows..

;  I substituted a  kmasked text entry field for SSN;  Using a kmasked 
entry field with a number field (SSN is an integer) forces one to 
address several issues:
;  ...1.-the format string will only pad extra 0's to the beginning of a 
number if the field is right justified
;  ...2.-the input mask of a number field will only work if the field is 
left justified
;  ...3.-implementing code to address issue #2 clashes with issue #1
;  Using a substitute, kmasked text field, for the SSN # requires 
several task completions in order to work properly:
;  ...1.-Going into the field, use an evBefore trap to pad 0 strings to 
the text field using a jst function
;  ...2.-Although not absolutely required, use an evAfter trap to check 
for a numerically zero value in the text field..If you get one, set the 
text string to ''; this will prevent the user from seeing '- - 0' when 
leaving the field.
;  ..3.-The text field hve the following attributes set as follows:  set 
$formatmode to kFormatCharacter, set $formatstring to PO@@@'-'@@'-'@@@@, 
and set $inputmask to >0###-##-####

On evBefore     ;; Event Parameters - pRow ( Itemreference )
   ;  going in, we want zero values or values with less than 9 
significant numbers to be prefixed (padded) with 0's
   Calculate ivSSNString as ivSSNString     ;; this prevents a level 2 
error..unused instance variable
  If pick(isnull(ivClientRow.SSN),ivClientRow.SSN,0)=0
    Calculate [$cobj.$dataname] as ''     ;; first, we set the field
    Calculate $cobj.$contents as ''     ;; second, we set the value seen 
in the window..we could also have just executed a'Do  
$cobj.$redraw(ktrue,ktrue)'
  Else
    Calculate [$cobj.$dataname] as jst(ivClientRow.SSN,'-9P0')     ;; 
first, we set the field
    Calculate $cobj.$contents as jst(ivClientRow.SSN,'-9P0')     ;; 
second, we set the value seen in the window..we could also have just 
executed a'Do  $cobj.$redraw(ktrue,ktrue)'
  End If
On evAfter     ;; Event Parameters - pClickedField, pClickedWindow, 
pMenuLine, pCommandNumber, pRow
  If $cobj.$contents=0
      ;  going out, we want empty values (all 9 digits are 0) to display 
as empty, thus we need to reformat the text field as '' and set SSN = 0
    Calculate $cobj.$contents as ''
    Calculate [$cobj.$dataname] as 0
    Calculate ivClientRow.SSN as [$cobj.$dataname]
  Else
    Calculate ivClientRow.SSN as [$cobj.$dataname]
  End If
  bla,bla, bla...

In our case, you need to set
    $formatstring to PO@@
    $formatmode   to kFormatCharacter
    $inputmask to >0##

terry


David Ferri wrote:
> Hi All,
>
> Background: We have a character field in a table defined as a length 
> of 2 that we use to store two digit numbers.  We do this because we 
> need to identify whether the user entered one digit, two digits or 
> nothing at all, and a numeric field will not allow us to do that (we 
> don't allow nulls).  On the data entry window that contains the field, 
> we have assigned an input mask of '##', so only numbers can be entered 
> into this character field.  We also have a formatting string of '00' 
> so any missing digits are filled in with zeros.
>
> Issue: In Omnis 7 (v7), entering a '1' in the field and then tabbing 
> out puts a '0' in front of the '1' making it '01'.  In Studio (v4.3), 
> entering a '1' in the field and then tabbing out keeps the cursor in 
> place, i.e it demands that a second digit be entered.  The input mask 
> and the formatting string in Omnis 7 and in Studio are the same, i.e. 
> '##' and '00', respectively.  We have verified that the behavior is 
> the same, i.e. different between the two Omnises, whether the field is 
> left, right or center justified, just in case that had an impact on 
> the way each program acted on the leading/trailing zeros.
>
> So my question is twofold:  Why is the behavior different between 
> Omnis 7 and Omnis Studio and is this difference a bug?  Is one 
> behavior more correct than the other, i.e. is the Studio version in 
> essence correcting an improper behavior in Omnis 7 or has Studio 
> introduced a behavior change i.e. a bug?



More information about the omnisdev-en mailing list