NetTalk Central

Author Topic: Decimal comma or period  (Read 4733 times)

rainerwallenius

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Email
Decimal comma or period
« on: December 11, 2014, 04:51:04 AM »
Hi all

Sorry if this topic is already covered but I did not find it so here comes the question.

What is the best way to handle decimal comma or period.
Best would be if the program could accept both a comma or period as decimal character, ie 123.23 or 123,23. Now we get 123.23 => 123.23 and 123,23=> 12323 which is not good. The finnish/swedish keyboard layout generates a comma from numpad and accountants are used to enter numeroc values from numpad.

My application consists of tens or hundred of forms and several hundred fields so manual change is not a very welcome suggestion.

Any help is appreciated (even an RTFM-answer if it pinpoints to the right place ;)

:: rainer

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Decimal comma or period
« Reply #1 on: December 11, 2014, 05:12:28 AM »
Hi Rainer,

are you using the STRING or NUMBER form field type?

Cheers
Bruce


rainerwallenius

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Email
Re: Decimal comma or period
« Reply #2 on: December 12, 2014, 12:39:22 AM »
Hi Bruce
Only STRING

:: rainer

rainerwallenius

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Email
Re: Decimal comma or period
« Reply #3 on: December 19, 2014, 12:00:06 AM »
Any ideas anybody?

Quote
What is the best way to handle decimal comma or period.
Best would be if the program could accept both a comma or period as decimal character, ie 123.23 or 123,23. Now we get 123.23 => 123.23 and 123,23=> 12323 which is not good. The finnish/swedish keyboard layout generates a comma from numpad and accountants are used to enter numeroc values from numpad.
where in the templates can I tweak this?

TIA
:: rainer

rainerwallenius

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Email
Re: Decimal comma or period
« Reply #4 on: December 19, 2014, 06:26:39 AM »
I made two changes in netweb.tpw (and a function)

Inside validation I use a function that returns a string that replaces comma with dot (if numeric values)
This does the magic

The downside is that I have to make sme changes every time Bruce updates Nettalk so if there is
a more generic way to do this, it would be great to hear about it.

:: rainer

############################################################################
      #End
  #Embed(%CustomValidate,'Validate New Value'),%FormID,TREE('Routines|'&%TabHeading&' Tab|'&%FormID&' Field|'&%FormID&' Field|Validate::'&%FormId&' Routine|4 Middle')
  If p_web.Ajax = 1 and p_web.ifExistsValue('NewValue')
      #IF((%FormFieldType<>'Browse') and (%FormField <>''))
        #IF(%FieldType='MEMO' or %FieldType='BLOB')
    bloblen = len(p_web.GetValue('NewValue'))
          #IF(%FieldType='MEMO')
    If BlobLen <= Len(%FormField)
      %FormField = p_web.GetValue('NewValue')
    End
          #ELSE
    %FormField[1 : bloblen] = p_web.GetValue('NewValue')
          #ENDIF
        #ElsIf(%FormFieldType='Color')
    %FormField = p_web.dFormat(NoComma(p_web.GetValue('NewValue')),'%FromFieldColorAs')  ! <================
        #ELSE
    %FormField = NoComma(p_web.GetValue('NewValue'))   ! <==============
        #ENDIF
      #ENDIF
      #case(%FormFieldType)
      #of('Slider')
###############################################################################

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Decimal comma or period
« Reply #5 on: January 01, 2015, 03:01:05 AM »
Hi Rainer,

I have added a smart number deformatter to build 8.34.
Note that his will require a StringTheory update (to 2.14 or later).

This will try and be "clever" about the number being entered. Specifically if the user enters a single , or . character then it will look at the picture to determine if decimal places are expected. If they are expected then it will be assumed that that is the decimal point.

cheers
Bruce

rainerwallenius

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Email
Re: Decimal comma or period
« Reply #6 on: January 01, 2015, 07:02:17 AM »
Hi Bruce

Sounds great!
Have a very succesful 2015!

:: rainer