on mouseDown
If field 1 as an example contains 197.256221
How do I extract all the numbers before a decimal point and place those into field 2 (in the example would be 197)
and then also extract all the numbers after a decimal point and place those into field 3 (in the example would be 256221)
Thanks
Dave
Extract numbers before and after decimal separator
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 16
- Joined: Tue Jan 13, 2015 1:21 am
Re: Extract numbers before and after decimal separator
David,davidmills wrote: How do I extract all the numbers before a decimal point
and then also extract all the numbers after a decimal point
Code: Select all
put "xxx 197.256221 yyyy " into T
if MatchText( T, "(\d+)\.(\d+)", n1, n2) then
put n1 into fld 1
put n2 into fld 2
end if
Thierry
PS: Someone else might certainly give you a more 'Livecodish' solution...
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Extract numbers before and after decimal separator
Code: Select all
put fld "1" into tNum --You should not name fields with only a number, it can cause errors
set the itemDelimiter to "."
put item 1 of tNum into containerForWholeNumber
put item 2 of tNum into containerForDecimalNumber
-
- Posts: 16
- Joined: Tue Jan 13, 2015 1:21 am
Re: Extract numbers before and after decimal separator
Thank you both for your help.
Dave
Dave