"," as delimiter of numerals

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

waldfeuer
Posts: 4
Joined: Fri May 09, 2014 4:17 am

"," as delimiter of numerals

Post by waldfeuer »

Hallo,
I am trying to set a "," as delimiter of numerals when using a Textbox, but a haven´t found the way yet.

I am using:
#include <hmg.ch>
#include <set.ch>
#include <i_lang.ch>

SET CODEPAGE To German
SET DATE German
SET LANGUAGE TO German

But there is no chance to get the "," as a delimiter in textboxes.

In German xbase forum ther is a notice to "SLEPIC". But whrer may I get it and how do I have to use it?
Is der another way with HMG I haven´t found yet?

Please help me.
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: "," as delimiter of numerals

Post by gfilatov »

waldfeuer wrote:Hallo,
I am trying to set a "," as delimiter of numerals when using a Textbox, but a haven´t found the way yet.
...
Is der another way with HMG I haven´t found yet?
Hello Gilbert,

Yes, it is. Hmg uses a 'Format' clause for handling this behavior of the Textbox control.
Format String
...
'E' - Displays points as thousand separator and comma as decimal separator.
Please take a look for the following simple sample from Hmg distribution (see TEXTBOX Text_11 definition):

Code: Select all

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

/*

	InputMask String For numeric textBox

        9	Displays digits
        $       Displays a dollar sign in place of a leading space 
        *       Displays an asterisk in place of a leading space 
        .       Specifies a decimal point position
        ,       Specifies a comma position

	Format String

        C       Displays CR after positive numbers
        X       Displays DB after negative numbers
        (       Encloses negative numbers in parentheses
	E	Displays points as thousand separator and comma as decimal 
		separator.

*/

#include "hmg.ch"

Function Main

	SET NAVIGATION EXTENDED

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 500 ;
		TITLE 'InputMask Demo' ;
		MAIN 

		DEFINE MAIN MENU
			POPUP 'Test'
				ITEM 'Get Text_1 Value' ACTION MsgInfo (Str(Form_1.Text_1.Value))
				ITEM 'Set Text_1 Value' ACTION Form_1.Text_1.Value := 123456.12
				ITEM 'Set Text_1 Focus' ACTION Form_1.Text_1.SetFocus
			END POPUP
		END MENU

		@ 10,10 TEXTBOX Text_1 ;
		VALUE 1234567.12 ;
		NUMERIC INPUTMASK "$9,999,999.99" 


		@ 50,10 TEXTBOX Text_2 ;
		VALUE 1234.56 ;
		NUMERIC INPUTMASK "$9,999.99" FORMAT 'CX' 


		@ 90,10 TEXTBOX Text_3 ;
		VALUE -123.0 ;
		NUMERIC INPUTMASK "999,999.99" FORMAT '('

		@ 130,10 TEXTBOX Text_4 ;
		VALUE 123.0 ;
		NUMERIC INPUTMASK "999.9" 	

		@ 170,10 TEXTBOX Text_5 ;
		VALUE -123.45 ;
		NUMERIC INPUTMASK "$9,999.99" FORMAT 'CX'

		@ 210,10 TEXTBOX Text_6 ;
		VALUE 1234.56 ;
		NUMERIC INPUTMASK "$***,999.99" 

		@ 250,10 TEXTBOX Text_7 ;
		VALUE 12345678.12 ;
		NUMERIC INPUTMASK "99999999.99" 

		@ 290,10 TEXTBOX Text_8 ;
		VALUE 1.1 ;
		NUMERIC INPUTMASK "9.9" 

		@ 330,10 TEXTBOX Text_9 ;
		VALUE 1234567890.12 ;
		NUMERIC INPUTMASK "$9999999999.99" 

		@ 370,10 TEXTBOX Text_10 ;
		VALUE 123456 ;
		NUMERIC INPUTMASK "$9999999" 

		@ 410,10 TEXTBOX Text_11 ;
			VALUE 1234.56 ;
			NUMERIC INPUTMASK "99,999.99" FORMAT 'E'

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return
Hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
waldfeuer
Posts: 4
Joined: Fri May 09, 2014 4:17 am

Re: "," as delimiter of numerals

Post by waldfeuer »

Hallo,
thanks for the fast answer.

But it daosn't work.

I am using ANSI IDE Version 2011.06.24. When I say FORMAT 'E' there is no change and INPUT '999,99' does not give me the result "99,99" when using the form.

When changing INPUTMASK To NUMERIC INPUTMASK by editor, I get a failior when starting.

The dataformat of my textbox is 'NUMERIC'

greetings
Gilbert
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: "," as delimiter of numerals

Post by mol »

waldfeuer wrote:Hallo,
thanks for the fast answer.

But it daosn't work.

I am using ANSI IDE Version 2011.06.24. When I say FORMAT 'E' there is no change and INPUT '999,99' does not give me the result "99,99" when using the form.

When changing INPUTMASK To NUMERIC INPUTMASK by editor, I get a failior when starting.

The dataformat of my textbox is 'NUMERIC'

greetings
Gilbert
You should use InputMask as '999.99' (with dot character)

Problem is with focus - when textbox is focused - it displays dot, when focus is out - it displays comma:
Image

Another question is how to display grid cells in this format - with comma as decimal point?

Grigori, do you know any solution?

Regards, Marek
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: "," as delimiter of numerals

Post by serge_girard »

Marek,

Did you try with TRANSFORM ?

Eg:

W_KORT_STU := TRANSFORM(W_KORT_STU, "@KE 999.99")
SetProperty('Form_ED4_F0001', 'T_NVERK' , 'Value', W_NVERKOPEN)

Greetings, Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: "," as delimiter of numerals

Post by mol »

But, we are writing about numeric type textbox
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

"," as delimiter of numerals

Post by Pablo César »

In this message I am suggesting to make some implementations, in order to recognize when ever needs to be comma "," or dot "." for decimals at TextBoxes. I know this always depending each country standards.

IMO this is perfectly possible to do it. We only need to be approved for HMG.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: "," as delimiter of numerals

Post by mol »

IMO, it should be solved at low level of HMG code.
We should declare at the beginning of program which character is decimal point and which is thousand separator.

From years it's clipper and harbour problem.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

"," as delimiter of numerals

Post by Pablo César »

mol wrote:From years it's clipper and harbour problem.
Yes, but now we can access API and we can know current environment from Windows. But of course we can count with the chance to let it as settable by the programmer. Also can be can be left preconfigured by i_lang.ch which keeps characteristics of some languages. probably will be choosen the SET DECIMAL CHARACTER TO <","/".">
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: "," as delimiter of numerals

Post by mustafa »

Hola amigos:
El tema de representar cantidades económicas númericas
de Ventas en Europa
He creado un sample de Generar una Factura con esta
carecteristica, utilizando "TRANSFORM".
Espero que les pueda servir el Sample.
Saludos
Mustafa
*------------------ Google -----------------------*
Hello friends:
The issue of economic quantities represent numerical
Sales in Europe
I created a sample to generate an invoice with this
carecteristica using "TRANSFORM".
Hope you can serve the Sample.
Regards
Mustafa
Attachments
Factura_HPDPRINT.zip
(887.24 KiB) Downloaded 346 times
screenshot.jpg
screenshot.jpg (266.06 KiB) Viewed 5833 times
Post Reply