Subject Re: numbers as text
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 8 Apr 2025 11:51:39 +0200
Newsgroups dbase.getting-started
Attachment(s) char_ints.wfm

On 2025/04/07 20:18, Charlie wrote:
> I have numbers as a string.  Might have asked this before but forgot.  I want to only use commas when user is working with them in entryfields or grids. .  Otherwise store them in the table as a string with no commas.   Using entryfields I have tried function @R 999,999,999,999 with no luck.  Can this be done without showing the commas on blank fields?

It should work.  In the Template Property Builder select @R and click
the Paste button to place it in the Template entryfield.  Add the
required picture and click the OK button.

When the form is compiled the template will be divided between the
Picture and Function properties.

You can edit the constructor code in the source code to add these
properties manually instead of using the Template Property Builder.  In
this case the @ is discarded.

A little example is attached.

Mervyn.


if file('char_ints.dbf')
// drop table char_ints
endif

if not file('char_ints.dbf')
   create table char_ints  (id autoinc,data character(15))
//endif

   insert into char_ints  (data) values ("123456789012345")
   insert into char_ints  (data) values ("234567890123456")
   insert into char_ints  (data) values ("345678901234567")
endif

** END HEADER -- do not remove this line
//
// Generated on 2025-04-08
//
parameter bModal
local f
f = new char_intsForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class char_intsForm of FORM
   with (this)
      height = 16.0
      left = 14.5714
      top = 5.2727
      width = 51.1429
      text = ""
   endwith

   this.CHAR_INTS1 = new QUERY(this)
   with (this.CHAR_INTS1)
      left = 5.0
      width = 8.0
      height = 1.0
      sql = 'select * from "char_ints.DBF"'
      active = true
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      dataLink = form.char_ints1.rowset.fields["data"]
      height = 1.0
      left = 26.0
      top = 1.8182
      width = 18.4286
      picture = "999,999,999,999,999"
      function = "R"
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.char_ints1.rowset
      columns["COLUMN1"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN1"])
         dataLink = form.char_ints1.rowset.fields["id"]
         editorType = 1        // EntryField
         width = 15.7143
      endwith
      columns["COLUMN2"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN2"])
         dataLink = form.char_ints1.rowset.fields["data"]
         editorType = 1        // EntryField
         width = 21.4286
      endwith
      with (columns["COLUMN1"].headingControl)
         value = "id"
      endwith

      with (columns["COLUMN2"].editorControl)
         picture = "999,999,999,999,999"
         function = "R"
      endwith

      with (columns["COLUMN2"].headingControl)
         value = "data"
      endwith

      height = 4.7273
      left = 5.4286
      top = 4.0455
      width = 41.5714
   endwith

   this.GRID2 = new GRID(this)
   with (this.GRID2)
      dataLink = form.char_ints1.rowset
      height = 4.7273
      left = 5.4286
      top = 10.6818
      width = 41.5714
   endwith

   this.TEXTLABEL1 = new TEXTLABEL(this)
   with (this.TEXTLABEL1)
      height = 1.0
      left = 5.4286
      top = 2.8182
      width = 12.0
      text = "With picture"
   endwith

   this.TEXTLABEL2 = new TEXTLABEL(this)
   with (this.TEXTLABEL2)
      height = 1.0
      left = 5.4286
      top = 9.6364
      width = 17.4286
      text = "Without picture"
   endwith

   this.rowset = this.char_ints1.rowset

endclass