Subject Re: ENTRYFIELD
From Mervyn Bick <invalid@invalid.invald>
Date Mon, 10 Jun 2019 10:49:54 +0200
Newsgroups dbase.getting-started
Attachment(s) Test_entryfield.wfm

On 2019-06-09 7:07 PM, Mustansir Ghor wrote:
> Dear All
>
> I have a situation where A test can have result in Character, Logical or Numeric. the result is captured by a single point ENTRYFIELD (not datalinked) and saved as Text is a field.
>
> In design form , when we insert ENTRYFIELD , in the value property we get diffrent option how to identify this entryfield (be it Boolean, Character,Numeric,Date etc).
>
> Can we set for this ENTRYFIELD its value type based on test chosen programatically.

The short answer is yes. :-)

The value saved in the entryfield's value property determines what can
be entered from the keyboard.  This value can be changed from your
program depending on what input you expect

oRef.value = ''   will accept all characters and digits.
oRef.value = false   will accept only T, t, F, f, Y, y, N or n
oRef.value = 0.00  will accept only digits and the decimal point symbol
which depends on the SET POINT setting.

The trouble with assigning either false or 0.00 to the value property is
that these show in the entryfield.  If you want the users to always see
a blank entryfield then a bit more work is involved.  Set the value to
'' and then use the entryfield's onKey event handler to monitor input
where logical or numeric input is expected.

A little example is attached.

Mervyn.






** END HEADER -- do not remove this line
//
// Generated on 2019-06-10
//
parameter bModal
local f
f = new Test_entryfieldForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class Test_entryfieldForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 16.0
      left = 74.0
      top = 0.0
      width = 40.0
      text = ""
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      onKey = class::ENTRYFIELD1_ONKEY
      height = 1.0
      left = 10.0
      top = 8.0
      width = 13.0
      value = false
   endwith

   this.RADIOBUTTON1 = new RADIOBUTTON(this)
   with (this.RADIOBUTTON1)
      onChange = class::RADIOBUTTON_ONCHANGE
      onLeftMouseUp = class::RADIOBUTTON_ONLEFTMOUSEUP
      height = 1.0909
      left = 10.0
      top = 1.0
      width = 15.7143
      text = "Character"
      group = true
      value = true
   endwith

   this.RADIOBUTTON2 = new RADIOBUTTON(this)
   with (this.RADIOBUTTON2)
      onChange = class::RADIOBUTTON_ONCHANGE
      onLeftMouseUp = class::RADIOBUTTON_ONLEFTMOUSEUP
      height = 1.0909
      left = 10.0
      top = 3.0
      width = 15.7143
      text = "Logical"
   endwith

   this.RADIOBUTTON3 = new RADIOBUTTON(this)
   with (this.RADIOBUTTON3)
      onChange = class::RADIOBUTTON_ONCHANGE
      onLeftMouseUp = class::RADIOBUTTON_ONLEFTMOUSEUP
      height = 1.0909
      left = 10.0
      top = 5.0
      width = 15.7143
      text = "Numeric"
   endwith

   this.ENTRYFIELD2 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD2)
      height = 1.0
      left = 10.0
      top = 11.5
      width = 13.0
      value = "Entryfield2"
   endwith


   function RADIOBUTTON_onLeftMouseUp(flags, col, row)
      form.entryfield1.setfocus()
      return

   function ENTRYFIELD1_onKey(nChar, nPosition,bShift,bControl)
      if form.radiobutton1.value = true
        //accept anything
      elseif form.radiobutton2.value = true
         if chr(nChar)$'TtYy'
            this.value = true  
         elseif chr(nChar)$'FfNn'
            this.value = false
         else
            msgbox('Must be T, t, F, f, Y, y, N or n')        
         endif
      elseif form.radiobutton3.value = true
         if not chr(nChar)$'0123456789.'
            msgbox('Must be numeric.')
         endif
      endif
      return

   function RADIOBUTTON_onChange()
      if form.radiobutton1.value = true
         form.entryfield1.value = ''
      elseif form.radiobutton2.value = true
         form.entryfield1.value = ''
      elseif form.radiobutton3.value = true
         form.entryfield1.value = ''
      endif
      return

   function form_onOpen()
      form.entryfield1.value = ''
      return

endclass