Hi,
Is it possible to put all sentences from single text field into individual text fields, ie, one sentence per field? can someone please give me an example?
Many thanks
Bidge
copying sentences script help
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
Re: copying sentences script help
Hi Bidge,
Please don't hesitate to rephrase your question if this doesn't answer your question.
As I understand it, your situation is one where I have a big text, stored in a field called "fulltext". Then, you have smaller text fields, for instance named "sentence1", "sentence2", "sentence3", etc. And you would like your big text to be transfered into these smaller text fields, one sentence at a time. I assume that by sentence you mean something ending with a return carriage.
To set up a default format for all fields that will come to be created, use the "templateField" construct (check out the doc for more information)
Best,
Marielle
Please don't hesitate to rephrase your question if this doesn't answer your question.
As I understand it, your situation is one where I have a big text, stored in a field called "fulltext". Then, you have smaller text fields, for instance named "sentence1", "sentence2", "sentence3", etc. And you would like your big text to be transfered into these smaller text fields, one sentence at a time. I assume that by sentence you mean something ending with a return carriage.
Code: Select all
on mouseup
pullSentencesFromText
end mouseup
on pullSentencesFromText
----------
-- removing all fields created on the previous round
deleteAllSentenceFields
----------
put the text of field "fulltext" into tText
----------
-- counting the number of sentences in the text
set the itemdel to cr -- return carriage
put the number of items in tText into tSentenceQty
----------
-- initialising a few variables
put 200 into tLeft; put 50 into tTop
put 1 into tSentenceNb
----------
-- creating text fields, one for each sentence
lock screen
repeat with tS = 1 to tSentenceQty
put item tS of tText into tSentence
if length(tSentence) < 3 then next repeat
create field "sentence" && tSentenceNb
put the long id of the last field into tFieldRef
set the text of tFieldRef to tSentence
set the top of tFieldRef to tTop
----------
add 40 to tTop
add 1 to tSentenceNb
end repeat
unlock screen
end pullSentencesFromText
on deleteAllSentenceFields
repeat with x = the number of controls on this card down to 1
if char 1 to 8 of the short name of control x of this card is "sentence" then delete control x of this card
end repeat
end deleteAllSentenceFields
Best,
Marielle
-
- Livecode Opensource Backer
You need to change the value for tLeft and tTop to something that works for you, then add set the left of tFieldRef to tLeft.bidgeeman wrote:I created the appropriate text fields and tried ruuning the script but for some reason the "sentence" text fields all jump up into the fulltext field.
Note that you don't need to create the text field beforehand, they get created within the script.