Page 1 of 1

Recovery from database digits with comma

Posted: Thu Feb 25, 2016 7:03 pm
by AlessioForconi
Having this code to retrieve data

Code: Select all

   put "SELECT * from annuali" into sqlAnnuali
   put revDataFromQuery(tab,return,connID,sqlAnnuali) into tAnnuali
   answer tAnnuali
   put item 2of tAnnuali into field "txtFerieAnnuali"
I get the data correctly, in fact answer shows 1 29,12 8,21
which they are respectively the id and two fields of the table.

I'm interested in 29,12 and 8,21 because they want to place in the two text boxes.
The problem arises because, with put item 2of tAnnuali into field "txtFerieAnnuali" due to the fact that they are figures with the decimal point, disrupts the data and mixes the numbers recovering 13 8.

Since I can not avoid the point because the decimal point is important in this case how do I fix?

Thank you.

Re: Recovery from database digits with comma

Posted: Thu Feb 25, 2016 11:06 pm
by Simon
Hi Alessio,
I'm afraid your post is a bit confusing to me but I did this

Code: Select all

on mouseUp
   put "1, 13.33, 7.33" into temp
   put item 2 of temp into fld 1
   put item 3 of temp into fld 2
end mouseUp
and the numbers came out correctly 13.33 and 7.33.
The decimal point had no effect.
Now if you are dealing with Europe numbering like 13,33 and 7,33 then yes I see the problem, but all you do is "set the itemDelimiter to tab" before you "put item 2...". Actually that is how you have set up your revDataFromQuery.

Simon

Re: Recovery from database digits with comma

Posted: Fri Feb 26, 2016 12:36 am
by jameshale
If I am reading this correctly your data is retrieved in the form:
id<tab>num1<tab>num2<return>

The simplest solution would be to set the item delimiter to "tab".
The item 2 would be your first number and item 3 would be the second.
put "SELECT * from annuali" into sqlAnnuali
put revDataFromQuery(tab,return,connID,sqlAnnuali) into tAnnuali
answer tAnnuali
set item delimiter to tab
put item 2 of tAnnuali into field "txtFerieAnnuali"

Re: Recovery from database digits with comma

Posted: Fri Feb 26, 2016 4:29 pm
by AlessioForconi
I had misspelled the data, I corrected the initial post...

Re: Recovery from database digits with comma

Posted: Fri Feb 26, 2016 4:37 pm
by Simon
Hi Alessio,
Thought so, but did I guess right?

Simon

Re: Recovery from database digits with comma

Posted: Fri Feb 26, 2016 6:00 pm
by AlessioForconi
Hi Simon,

thought of as?

Re: Recovery from database digits with comma

Posted: Fri Feb 26, 2016 6:17 pm
by quailcreek
Hi AlessioForconi,
I'm thinking you want to use a comma instead of a decimal point as the separator, right? Try this.

Code: Select all

on mouseUp
   set the itemDel to tab
   put "1" & tab & "13,33" & tab & "7,33" into temp
   put item 2 of temp into fld 1
   put item 3 of temp into fld 2
   set the itemDel to comma
end mouseUp