TELEPHONE INPUTMASK IN A GRID

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

mexicanto

TELEPHONE INPUTMASK IN A GRID

Post by mexicanto »

HELLO EVERYBODY

DIRECTLY TO MY QUESTION

I AM USING A GRID, ONE OF THE FIELDS IN THE DATABASE IS
"CLIENTES->CLI_TE1" TYPE CHARACTER LENGHT 10

SO IS LIKE 1234567890

HOW CAN I DISPLAY THAT FIELD IN A GRID IN THIS FORMAT : (123) 456-7890

IS FOR THE TELEPHONE NUMBER HERE UN U.S.A

I AM VERY VERY NEWBIE IN HMG, I CAME BACK TO PROGRAMING FROM 20 YEARS
WITHOUT PROGRAMING, MY LAST LENGUAGE WAS CLIPPER SUMMER 87

THANK YOU TO ALL YOU, FOR THE RESPONSE, AND FOR THIS PROGRAM
mexicanto

Re: TELEPHONE INPUTMASK IN A GRID

Post by mexicanto »

ONE NOTE
I THINK I CAN CONVERT THE FIELD TO NUMERIC
BUT JUST FOR TRAINING, IN CASE I NEED TO PUT MORE
INPUTMASK IN OTHER CHARACTER FIELDS LIKE :

"ABC745HSS3" DISPLAYED IN THE GRID LIKE "ABC-745-HSS3"

MI PRIMER LENGUA ES EL ESPANOL, SOY DE MEXICO, PERO VIVO EN CALIFORNIA, USA
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: TELEPHONE INPUTMASK IN A GRID

Post by l3whmg »

Ciao Mexicanto

I'm not a guru but I think you don't have solution with standard HMG (rel. 3) properties, for some reason.
My answer is based upon TEXTBOX control properties and benefits (COLUMNCONTROLS is a derived definition) and my little experience.

First: you can define and use only one COLUMNCONTROLS property for the same column (see manual)
For this reason you can use (theorically) OR this picture code "(999) 999-999" OR this one "(AAA) AAA-AAA" (see below).

Second: COLUMNCONTROLS picture mask can only control NUMERIC character (see picture code 9) or ALPHABETIC character (see picture code A) but not ALPHANUMERIC character (there isn't "N" or "X" picture code like CA-Clipper). The default picture mask code is " " (space) to enter any character, but you can't use a mask like this "( ) - " (see TEXTBOX control).

Third: with TEXTBOX control and for CHARACTER datatype and INPUTMASK you pay attention to the real lenght of the field.

For these reasons (I think) you must manage data before load into grid and use a generic COLUMNCONTROLS masked picture like {"TEXTBOX", "CHARACTER"} to (only) printout data.
For example: when you explore (and load data) into the grid, you must create a function to do something like this:

Code: Select all

If AllCharOf( cValue ) Are Numeric
 Return cNewValue Formatted Like "(999) 999-999"
Else
 Return cNewValue Formatted Like "XXX-XXX-XXXX"
Endif

MyForm.Grid.AddItem( {cNewValue} )
Any way, I think you have another problem: when user must enter data.

Little brief about Italy: we have only numeric value for fixed and mobile phone but not a standard formatting rule.
Fixed numbers are (normally) like 0124745264 or 01176842795 while mobile number are 34756377272, 335755252, 376850965. We now that: if the number begin with 0 is a fixed phone else if begin with 3 it's a mobile phone (there are other numbering set often fixed phone). When you call a fixed phone from U.S. you must use this number 039124745264 where 039 is international prefix for Italy and then the number but omitting the first 0 (zero)

At this moment, it is my best answer.
I hope there is someone who can provide a better solution than mine

Best regards
Luigi from Italy
www.L3W.it
mexicanto

Re: TELEPHONE INPUTMASK IN A GRID

Post by mexicanto »

ciao

than you very much for the info

i will try the examples, and later on i will publish the results

thanks again for your response

(any time i see something about italy, the images that comes to my mind are "TOTO !!...ALFREDO !!" from cinema paradiso
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: TELEPHONE INPUTMASK IN A GRID

Post by Rathinagiri »

Second: COLUMNCONTROLS picture mask can only control NUMERIC character (see picture code 9) or ALPHABETIC character (see picture code A) but not ALPHANUMERIC character (there isn't "N" or "X" picture code like CA-Clipper). The default picture mask code is " " (space) to enter any character, but you can't use a mask like this "( ) - " (see TEXTBOX control).
Try this code for various combinations. Does any of these suit you? This is from /hmg/samples/inputmask.2

Code: Select all

/*
* HMG InputMask Demo
* (c) 2003 Roberto lopez
*/

/*

	InputMask String For Character TextBox

        9	Displays digits
	!       Displays Alphabetic Characters (uppercase)
	A	Displays Alphabetic Characters

	(All other characters are included in text in the position indicated 
	by the mask)

	Format String

	No Format Stirng Is Allowed For Character TextBox

*/

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 450 ;
		HEIGHT 250 ;
		TITLE 'InputMask Demo' ;
		MAIN 

		DEFINE MAIN MENU
			POPUP 'Test'
				ITEM 'Get Text_1 Value' ACTION MsgInfo (Form_1.Text_1.Value)
				ITEM 'Set Text_1 Value' ACTION Form_1.Text_1.Value := 'GEW-57927/X'
				ITEM 'Set Text_1 Focus' ACTION Form_1.Text_1.SetFocus
				SEPARATOR
				ITEM 'Get Text_2 Value' ACTION MsgInfo (Form_1.Text_2.Value)
				ITEM 'Set Text_2 Value' ACTION Form_1.Text_2.Value := '123.456.789-12' 
				ITEM 'Set Text_2 Focus' ACTION Form_1.Text_2.SetFocus
				SEPARATOR
				ITEM 'Get Text_3 Value' ACTION MsgInfo (Form_1.Text_3.Value)
				ITEM 'Set Text_3 Value' ACTION Form_1.Text_3.Value := '12.345.678' 
				ITEM 'Set Text_3 Focus' ACTION Form_1.Text_3.SetFocus
				SEPARATOR
				ITEM 'Get Text_4 Value' ACTION MsgInfo (Form_1.Text_4.Value)
				ITEM 'Set Text_4 Value' ACTION Form_1.Text_4.Value := '1234-1234-1234-1234' 
				ITEM 'Set Text_4 Focus' ACTION Form_1.Text_4.SetFocus
				SEPARATOR
				ITEM 'Get Text_5 Value' ACTION MsgInfo (Form_1.Text_5.Value)
				ITEM 'Set Text_5 Value' ACTION Form_1.Text_5.Value := 'AA-999/9(A-AAA)'   
				ITEM 'Set Text_5 Focus' ACTION Form_1.Text_5.SetFocus
				SEPARATOR
				ITEM 'Get Text_6 Value' ACTION MsgInfo (Form_1.Text_6.Value)
				ITEM 'Set Text_6 Value' ACTION Form_1.Text_6.Value := '(253) 427 - 7362'   
				ITEM 'Set Text_6 Focus' ACTION Form_1.Text_6.SetFocus

			END POPUP
		END MENU

		@ 10,10 LABEL label_1 ;
			VALUE 'Simple Code:' ;
			WIDTH 100

		@ 10,120 TEXTBOX text_1 ;
			VALUE 'ZFA-17529/Z' ;
			INPUTMASK 'AAA-99999/A'

		@ 10,290 LABEL label_1b ;
			VALUE 'AAA-99999/A' 
			WIDTH 100

		@ 40,10 LABEL label_2 ;
			VALUE 'Brazil ID:' ;
			WIDTH 100 

		@ 40,120 TEXTBOX text_2 ;
			VALUE '123.456.789-12' ;
			INPUTMASK '999.999.999-99' 

		@ 40,290 LABEL label_2b ;
			VALUE '999.999.999-99' 

		@ 70,10 LABEL label_3 ;
			VALUE 'Argentina ID:' ;
			WIDTH 100

		@ 70,120 TEXTBOX text_3 ;
			VALUE '12.123.123' ;
			INPUTMASK '99.999.999' 

		@ 70,290 LABEL label_3b ;
			VALUE '99.999.999' 


		@ 100,10 LABEL label_4 ;
			VALUE 'Credit Card:' ;
			WIDTH 100

		@ 100,120 TEXTBOX text_4 ;
			WIDTH 150 ;
			VALUE '1234-1234-1234-1234' ;
			INPUTMASK '9999-9999-9999-9999' 

		@ 100,290 LABEL label_4b ;
			VALUE '9999-9999-9999-9999' ;
			WIDTH 160

		@ 130,10 LABEL label_5 ;
			VALUE 'Complex Code:' ;
			WIDTH 100

		@ 130,120 TEXTBOX text_5 ;
			WIDTH 130 ;
			VALUE 'JZ-123/4(X-DKS)' ;
			INPUTMASK 'AA-999/9(A-AAA)'  

		@ 130,290 LABEL label_5b ;
			VALUE 'AA-999/9(A-AAA)' 

		@ 160,10 LABEL label_6 ;
			VALUE 'Phone Number:' ;
			WIDTH 100

		@ 160,120 TEXTBOX text_6 ;
			WIDTH 130 ;
			VALUE '(651) 384 - 8372' ;
			INPUTMASK '(999) 999 - 9999'  

		@ 160,290 LABEL label_6b ;
			VALUE '(999) 999 - 9999'  

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return




East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
mexicanto

Re: TELEPHONE INPUTMASK IN A GRID

Post by mexicanto »

thanks rathi

but the problem is, that i want the mask in a grid, with a numeric field

i overcome the problem, just change the field to a character, and then, in an textbox, in the capture time
put the inputmask

thank to all you

anyway, i have 3 questions, or consulting from you

1.- how to capture an image from a web cam, and store it in a field in a database

2.- how to capture a fingerprint from a fingerprint reader and store it in a database, and later on check it
(is for a employee time card checking, lite a time clock), the example is for the employee to put the finger
in the fingerprint reader, and the program "check in" or "check out" the employee to later on print a time assistance
computing the hours worked
3.- how to scan a document and store it in a data base, like id, or social security cards

all are almost the same

does anyone have a code for that ?

thank you very much in advance
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: TELEPHONE INPUTMASK IN A GRID

Post by l3whmg »

Hi guys,
"Cinema Paradiso" it's a beatiful movie; I think: every young person or child should watch ;)
About other problems, I do not have sufficient knowledge.
Just think, having to store images, there are two possibilities: either store the path of the image file or save the file in a field. In the latter case, I have a question: dbf or another?

Rathi, I hope my explanation it's clear and good :roll: What do you think :?:

About original request, theoretically, he had need two formats because he could have different values (letters or numbers) contained in the same character field (I add: sometime can be a mixture).
Problem: for every coloumn I can define only one columncontrols mask.
I think it would be useful to have an alphanumeric picture code ("X" or "N" like like in CA-Clipper) to printout a mix of characters.
Example. Mask "(XXX) XXX-XXXX" I can printout: "(123) 456-7890", "(aBc) dEf-gHij" and "(1B3) c56-H89j".

Do you think there will be, in the new version of HMG, the possibility of entering a code mask similar to what I presented?

This it's a code for Mexicanto

Code: Select all

MEMVAR _HMG_SYSDATA

#include "hmg.ch"

/*.....................................................................
 main function
.....................................................................*/
FUNCTION main()

 SET CENTURY ON
 SET DATE FORMAT "yyyy/mm/dd"

 DefineForm()

 ACTIVATE WINDOW ALL

 RETURN NIL

/*.....................................................................
 define form
.....................................................................*/
STATIC FUNCTION DefineForm()

 LOCAL aCol1 := {"TEXTBOX", "CHARACTER"}
 LOCAL aCol2 := {"TEXTBOX", "NUMERIC", "999,999.99", "999,999.99"}
 LOCAL aCol3 := {"TEXTBOX", "CHARACTER"}
 LOCAL aCol4 := {"TEXTBOX", "DATE"}
 LOCAL aCol5 := {"TEXTBOX", "CHARACTER", "(999) 999-9999"}
 LOCAL aCol6 := {"TEXTBOX", "CHARACTER", "(999) 999-9999"}
 LOCAL aGridHdr := { "Alphabetic", "Numeric", "AlphaNum", "Date", "NumForm", "NumForm2" }
 LOCAL aGridWdt := { 100, 100, 100, 100, 100, 100 }
 LOCAL aGridCls := { aCol1, aCol2, aCol3, aCol4, aCol5, aCol6 }
 LOCAL aGridJst := { GRID_JTFY_LEFT, GRID_JTFY_RIGHT, GRID_JTFY_LEFT, GRID_JTFY_CENTER, GRID_JTFY_LEFT, GRID_JTFY_LEFT }
 LOCAL aGridOrd := { { || ChgOrd(1)}, { || ChgOrd(2)}, { || ChgOrd(3)}, { || ChgOrd(4)}, { || ChgOrd(5)}, { || ChgOrd(6)} }

 SET NAVIGATION EXTENDED
 DEFINE WINDOW MaiFrm ;
  ROW 0 ;
  COL 0 ;
  WIDTH 750 ;
  HEIGHT 555 ;
  WINDOWTYPE MAIN ;
  TITLE "Input test" ;
  SYSMENU .T. ;
  ON INIT MaiFrm_OnInit() ;
  FONTNAME "Arial" FONTSIZE 10

  DEFINE TEXTBOX Field1
   ROW 30
   COL 20
   HEIGHT 25
   WIDTH 150
   INPUTMASK "999,999.999"
   TOOLTIP "Numeric"
   ONENTER DsplInfo1()
   DATATYPE NUMERIC
  END TEXTBOX
  DEFINE LABEL lb1
   ROW 30
   COL 200
   VALUE "Mask '999,999.999', DATATYPE NUMERIC declared. Without this you can't digit '.'"
   WIDTH 500
   HEIGHT 30
  END LABEL

  DEFINE TEXTBOX Field2
   ROW 90
   COL 20
   HEIGHT 25
   WIDTH 150
   INPUTMASK "(999) 999-9999"
   TOOLTIP "Numeric U.S. phone number"
   ONENTER DsplInfo2()
  END TEXTBOX
  DEFINE LABEL lb2
   ROW 90
   COL 200
   VALUE "Mask '(999) 999-9999', no DATATYPE declared."
   WIDTH 500
   HEIGHT 30
  END LABEL

  DEFINE TEXTBOX Field3
   ROW 150
   COL 20
   HEIGHT 25
   WIDTH 150
   INPUTMASK "(AAA) AAA-AAAA"
   TOOLTIP "Character U.S. phone number"
   ONENTER DsplInfo3()
  END TEXTBOX
  DEFINE LABEL lb3
   ROW 150
   COL 200
   VALUE "Mask '(AAA) AAA-AAAA', no DATATYPE declared."
   WIDTH 500
   HEIGHT 30
  END LABEL

  DEFINE TEXTBOX Field4
   ROW 210
   COL 20
   HEIGHT 25
   WIDTH 150
   TOOLTIP "Free textbox"
   ONENTER DsplInfo4()
   DATATYPE CHARACTER
  END TEXTBOX
  DEFINE LABEL lb4
   ROW 210
   COL 200
   VALUE "No Mask, DATATYPE CHARACTER declared."
   WIDTH 500
   HEIGHT 30
  END LABEL

  DEFINE GRID grid1
   ROW 270
   COL 20
   WIDTH 650
   HEIGHT 200
   HEADERS aGridHdr
   WIDTHS aGridWdt
   COLUMNCONTROLS aGridCls
   JUSTIFY aGridJst
   ONHEADCLICK aGridOrd
  END GRID

 END WINDOW

 RETURN NIL

/*.....................................................................
 OnInit event
.....................................................................*/
STATIC FUNCTION MaiFrm_OnInit()

 MaiFrm.Center

 LoadDataIntoGrid()

 MaiFrm.Field3.Value := "(ABC) DEF-GHIJ"

 RETURN NIL

/*.....................................................................
 display information about Field1
.....................................................................*/
STATIC FUNCTION DsplInfo1()
 
 MSGSTOP( "ValType is " + VALTYPE( MaiFrm.Field1.Value ) )

 IF VALTYPE( MaiFrm.Field1.Value )  == "C"
  MSGSTOP( "Len is " + HB_VALTOEXP( LEN( MaiFrm.Field1.Value ) ) )
  MSGSTOP( "Value is " + MaiFrm.Field1.Value )
 ELSE
  MSGSTOP( "Value is " + HB_VALTOEXP( MaiFrm.Field1.Value ) )
 ENDIF

 RETURN NIL

/*.....................................................................
 display information about Field2
.....................................................................*/
STATIC FUNCTION DsplInfo2()

 MSGSTOP( "ValType is " +  VALTYPE( MaiFrm.Field2.Value ) )

 IF VALTYPE( MaiFrm.Field2.Value )  == "C"
  MSGSTOP( "Len is " + HB_VALTOEXP( LEN( MaiFrm.Field2.Value ) ) )
  MSGSTOP( "Value is " + MaiFrm.Field2.Value )
 ELSE
  MSGSTOP( "Value is " + HB_VALTOEXP( MaiFrm.Field2.Value ) )
 ENDIF

 RETURN NIL

/*.....................................................................
 display information about Field3
.....................................................................*/
STATIC FUNCTION DsplInfo3()

 MSGSTOP( "ValType is " +  VALTYPE( MaiFrm.Field3.Value ) )

 IF VALTYPE( MaiFrm.Field3.Value )  == "C"
  MSGSTOP( "Len is " + HB_VALTOEXP( LEN( MaiFrm.Field3.Value ) ) )
  MSGSTOP( "Value is " + MaiFrm.Field3.Value )
 ELSE
  MSGSTOP( "Value is " + HB_VALTOEXP( MaiFrm.Field3.Value ) )
 ENDIF

 RETURN NIL

/*.....................................................................
 display information about Field4
.....................................................................*/
STATIC FUNCTION DsplInfo4()

 MSGSTOP( "ValType is " +  VALTYPE( MaiFrm.Field4.Value ) )

 IF VALTYPE( MaiFrm.Field4.Value )  == "C"
  MSGSTOP( "Len is " + HB_VALTOEXP( LEN( MaiFrm.Field4.Value ) ) )
  MSGSTOP( "Value is " + MaiFrm.Field4.Value )
 ELSE
  MSGSTOP( "Value is " + HB_VALTOEXP( MaiFrm.Field4.Value ) )
 ENDIF

 RETURN NIL

/*.....................................................................
 Load data into grid
.....................................................................*/
STATIC FUNCTION LoadDataIntoGrid()

 MaiFrm.grid1.AddItem( {"aBcDeFgH",   123.45, "3C7OU6", DATE(), 1234567890, "(123) 456-7890" } )
 MaiFrm.grid1.AddItem( {"d Value",  12354.67, "4Bc3oN3", DATE()-10, 4508123796, "(450) 812-3796" } )
 MaiFrm.grid1.AddItem( {"b Value", 543567.12, "2I5rh34", DATE()-20, 1357908642, "(135) 790-8642" } )

RETURN NIL

/*.....................................................................
 Change Order
.....................................................................*/
STATIC FUNCTION ChgOrd( nOrder )

 LOCAL aTemp := {}
 LOCAL nX

 FOR nX := 1 TO MaiFrm.grid1.ItemCount
  AADD( aTemp, MaiFrm.grid1.Item( nX ) )
 NEXT nX

 aTemp := ASORT( aTemp,,,{|a,b| a[nOrder]<=b[nOrder]} )

 MaiFrm.grid1.DeleteAllItems
 FOR nX := 1 TO LEN( aTemp )
  MaiFrm.grid1.AddItem( aTemp[nX] )
 NEXT nX

 MaiFrm.grid1.Value := 1

RETURN NIL
Luigi from Italy
www.L3W.it
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: TELEPHONE INPUTMASK IN A GRID

Post by Rathinagiri »

Hmm. That we have to think of Luigi.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
mexicanto

Re: TELEPHONE INPUTMASK IN A GRID

Post by mexicanto »

cinema paradiso, thief of bicycles, etc etc etc

guiseppe tarnatore, ennio morricone, the perfect combination

india...bollywood..."childens of heaven"..

as you can see, i like foreing movies, i think i will start a topic in the "off topics" area about "movies from my country that you have to see", there, you can recomend me movies from your contry

back to the question

i solve my main problem, following the examples in "contactos" samples, thanks again for your cooperation

for the other 3 request:

if someone have a code, or want to write the code and the library, i am willing to pay (sorry, will be in american dollars, wire transfer) for that task that i need

just have to follow this directions :

ability to store the scan, capture image, and use the fingerprint in the database, not in a external file

the code will be use it in different programs, for different purposes,so no royalty fees for the each machine or program i will use it

i need the source code

full of explanation, because i am coming back from clipper summer 87, not ca-clipper, so i am a very beginner in the gui interfase, i still learning about methods, properties, etc

if somebody is interested in this project, just let me know how much are going to ask fot that (the price)

thabk you very much for you time and patience with me

atte

daniel gaitan (mexicanto)
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: TELEPHONE INPUTMASK IN A GRID

Post by l3whmg »

Hi Rathi,
I'm sorry but I don't understand your replay or I write a bad English.
When I ask to you "What do you think" I'm referring to my contribute not to me :lol:
In too many forum I find people who answer without give a good contribute and when I writed
"you don't have solution with standard HMG (rel. 3) properties" I hope don't write a mistake :roll:

Best regards (IT: migliori saluti) but I prefer Ciao.
Luigi from Italy
www.L3W.it
Post Reply