NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Jeffrey Kuijt on February 02, 2012, 06:25:42 AM
-
Hi Bruce,
I have changed my Number Fields to String Fields and use a numeric picture.
We have customers that use a COMMA as decimal, for example: 1,25
But we have also customers that use a PERIOD as decimal, for example 1.25
At this moment I have a string field with picture @N5`2B (comma as decimal separator), but this only accepts a COMMA.
When I use a PERIOD, it's going wrong.
So the question is:
How do I accept on a string field the pictures @N5`2B (comma as decimal separator) AND @N5.2B (period as decimal separator)?
I hope there is a solution!
Best regards
Jeffrey
-
I would leave it as a string without a format. Then parse out the comma and period in the client side tab's server code.
Set both the variable and its session value.
-
The other option is to set the Picture to a session value. If your users login you could store this as part of their setup (I do this for date formats). Alternatively you could try to detect what country the user is logging in from via their IP address and set the format accordingly.
-
this is a suitably interesting question that it's worthy of an interesting answer.
Firstly, we need to consider ways numbers can be typed in; and then we'll deal with your special case.
nnn-nn, nn-nn, n-nn, n, nn, nnn nn-n
are all fairly unambiguous. the separator, be it , or . is the decimal indicator.
if the number can be more than 999.99 though you get a complication. Because then you could have
n,nnn.nn or n.nnn,nn so the algorithm for parsing the number needs to be more complex.
fortunately in your case the number is @n5.2 so that's not a consideration for now.
Secondly we want to embed code in one place, but which works for both the immediate field, and also when the user clicks on Save. That means the ValidateValue::Fieldname embed.
the following code translates a , into a .
num string(15)
x long
If p_web.RequestAjax = 1 and p_web.ifExistsValue('Value')
p_web.SetValue('ALI:Roman',p_web.GetValue('Value'))
end
num = p_web.GetValue('ALI:Roman')
x = instring(',',num,1,1)
if x > 0
num[ x ] = '.'
end
ali:roman = num
The first IF takes care of the dynamic case, after that the Ali:Roman field is "re-parsed" from the original "value".
Any questions?
-
Thank you guys!
Bruce, you have made it even more simple.
Please look at the screenshot.
This works just out of the box! ;)
So now I can use a COMMA and/or a PERIOD as decimal separator.
After accepting the field, always a PERIOD is shown as decimal separator, but that's ok for me.
Best regards
Jeffrey
[attachment deleted by admin]
-
Jeffrey,
Did that fix it without the embed code???
Brilliant!
chris
-
Hi Chris,
Yes, it did! ;D
Best regards
Jeffrey