Recovery from database digits with comma

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Recovery from database digits with comma

Post by AlessioForconi » Thu Feb 25, 2016 7:03 pm

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.
Last edited by AlessioForconi on Fri Feb 26, 2016 4:28 pm, edited 2 times in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Recovery from database digits with comma

Post by Simon » Thu Feb 25, 2016 11:06 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Recovery from database digits with comma

Post by jameshale » Fri Feb 26, 2016 12:36 am

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"

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Recovery from database digits with comma

Post by AlessioForconi » Fri Feb 26, 2016 4:29 pm

I had misspelled the data, I corrected the initial post...

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Recovery from database digits with comma

Post by Simon » Fri Feb 26, 2016 4:37 pm

Hi Alessio,
Thought so, but did I guess right?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Recovery from database digits with comma

Post by AlessioForconi » Fri Feb 26, 2016 6:00 pm

Hi Simon,

thought of as?

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Recovery from database digits with comma

Post by quailcreek » Fri Feb 26, 2016 6:17 pm

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
Tom
MacBook Pro OS Mojave 10.14

Post Reply