Converting text to row
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 33
- Joined: Tue Apr 17, 2012 9:50 am
Converting text to row
Hello,
I need to converting a text to Row... but i cannot find the good loop!!!
the text is like that:
Société1
adresse1
Cp1
Ville1
Société2
adresse2
Cp2
Ville2
and i want to convert like that :
Société1 tab Adresse1 tab etc...
Société2 tab Adresse2 tab etc
All the six lines of field "text 1" must be a new row in the field "text2". I need two loop but which one!!! but how to change any of the six data lines
Thank you for yours help
Eric
I need to converting a text to Row... but i cannot find the good loop!!!
the text is like that:
Société1
adresse1
Cp1
Ville1
Société2
adresse2
Cp2
Ville2
and i want to convert like that :
Société1 tab Adresse1 tab etc...
Société2 tab Adresse2 tab etc
All the six lines of field "text 1" must be a new row in the field "text2". I need two loop but which one!!! but how to change any of the six data lines
Thank you for yours help
Eric
Re: Converting text to row
Since you know there are six lines to be extracted into rows, you can:
But please read this carefully and understand what is going on.
Craig Newman
Code: Select all
on mouseUp
get fld "yourField"
repeat with u = 1 to the number of lines of it
repeat with y = 1 to 6
put line y of it & tab after temp
end repeat
put return after temp
delete line 1 to 6 of it
end repeat
answer temp
end mouseUp
Craig Newman
Re: Converting text to row
Or another way
But please read this carefully and understand what is going on.
Craig Newman
Code: Select all
on mouseUp
get fld "yourField"
put 1 into tCounter
repeat until tCounter = the number of lines of it
put line tCounter of it & tab after temp
add 1 to tCounter
if tCounter mod 6 = 0 then put return after temp
end repeat
answer temp
end mouseUp
Craig Newman
-
- Livecode Opensource Backer
- Posts: 33
- Joined: Tue Apr 17, 2012 9:50 am
Re: Converting text to row
Hi Craig,
I try your handler and i come back
Thank you
I try your handler and i come back
Thank you
-
- Livecode Opensource Backer
- Posts: 33
- Joined: Tue Apr 17, 2012 9:50 am
Re: Converting text to row
The first Handler work after some adjusment.
After the line 8 i need delete line 9
on mouseUp
put fld "text2" into DataA
Repeat for each lines theLine in DataA
if the last char of thelIne is Space or TAB then
delete the last char of theline
end if
if the first char of thelIne is Space then
delete the first char of theline
end if
Put theLine & return after DataB
end Repeat
put DataB into DataA
repeat with u = 1 to the number of lines of DataA
repeat with y = 1 to 8
add 1 to NewSet
put line y of DataA & tab after temp
end repeat
put return after temp
delete line 1 to 9 of DataA
end repeat
put temp into fld "result"
--answer temp
end mouseUp
Your second handler work but we need to put
add 1 to tCounter after "if tCounter mod 8 = 0 then put return after temp"
But i cannot do what i want after.
A question How put the Livecode into the reply?
Thank you Craig for your help
After the line 8 i need delete line 9
on mouseUp
put fld "text2" into DataA
Repeat for each lines theLine in DataA
if the last char of thelIne is Space or TAB then
delete the last char of theline
end if
if the first char of thelIne is Space then
delete the first char of theline
end if
Put theLine & return after DataB
end Repeat
put DataB into DataA
repeat with u = 1 to the number of lines of DataA
repeat with y = 1 to 8
add 1 to NewSet
put line y of DataA & tab after temp
end repeat
put return after temp
delete line 1 to 9 of DataA
end repeat
put temp into fld "result"
--answer temp
end mouseUp
Your second handler work but we need to put
add 1 to tCounter after "if tCounter mod 8 = 0 then put return after temp"
But i cannot do what i want after.
A question How put the Livecode into the reply?
Thank you Craig for your help
Re: Converting text to row
Glad you are able to make both methods work. These were just to point you in the right direction, and you seem to be capable.
Both are dependent on the original data having a definite structure, because the code assumes a precise ordering and total number of lines. It is much more robust to create your original data in a more flexible format.
You seem to have loaded your newly parsed data into fields. What do you mean by "put LC into the reply?"
Craig Newman
Both are dependent on the original data having a definite structure, because the code assumes a precise ordering and total number of lines. It is much more robust to create your original data in a more flexible format.
You seem to have loaded your newly parsed data into fields. What do you mean by "put LC into the reply?"
Craig Newman
-
- Livecode Opensource Backer
- Posts: 33
- Joined: Tue Apr 17, 2012 9:50 am
Re: Converting text to row
Hi Craig,
I mean
How is it possible to display in a post the script like on your reply. I think i need to use and for a image . But i can not do.
Au revoir
I mean
How is it possible to display in a post the script like on your reply. I think i need to use
Code: Select all
Au revoir
Re: Converting text to row
Well, for code you just paste the code between the "code" setup from the buttons on top of the reply field. There is a blinking cursor to indicate where the paste should go, just like in any field.
I never sent an image, so I am not sure what form it needs to be in. I tried a few things and nothing appears. Someone please help...
Craig Newman
Code: Select all
Just paste some text
Craig Newman