Page 2 of 2
Re: How to use WordOffset to cut some text??
Posted: Fri May 28, 2021 3:48 pm
by Fasasoftware
I thank you so much to every body but i have had success with my piece of code.....Thanks a lot again!!!! Lestroso
Code: Select all
local testofinale
local ntotale
on mouseUp
delOneWord
end mouseUp
on delOneWord
put the num of chars of field "result" into ntotale
FIND "NEXT"
put THE FOUNDTEXT INTO testoinizio
put wordoffset(testoinizio,fld"result") into testoinizio
delete word 1 to testoinizio of fld "RESULT"
find"Results"
put THE FOUNDTEXT INTO testofinale
put wordoffset(testofinale,fld"result") into testofinale
delete word testofinale to ntotale of fld "RESULT"
put fld"result" into fld "giocare"
end delOneWord
Re: (Solved)How to use WordOffset to cut some text??
Posted: Fri May 28, 2021 4:08 pm
by Klaus
Buongiorno Lestroso,
no need to FIND anything, since you KNOW that these words are in that field!
Code: Select all
...
on delOneWord
## See below!
## put the num of chars of field "result" into ntotale
put the num of WORDS of field "result" into ntotale
## FIND "NEXT"
## put THE FOUNDTEXT INTO testoinizio
## THE FOUNDTEXT/testoinizio will contain... TADA -> NEXT
## So this does not make any sense! :-D
## So we just do:
put wordoffset("NEXT",fld "result") into testoinizio
delete word 1 to testoinizio of fld "RESULT"
## SAME HERE!
## find"Results"
## put THE FOUNDTEXT INTO testofinale
put wordoffset("Results",fld "result") into testofinale
## ntotale will hold the number of CHARACTERS in that field
## But we need the number of WORDS in that field for the next line!
delete word testofinale to ntotale of fld "RESULT"
put fld "result" into fld "giocare"
end delOneWord
Ciao
Klaus (Claudio Maggiore)
Re: (Solved)How to use WordOffset to cut some text??
Posted: Fri May 28, 2021 5:37 pm
by Fasasoftware
THANKS KLAUS!!!thanks a lot for your comment....Best regards, Lestroso

Re: How to use WordOffset to cut some text??
Posted: Fri May 28, 2021 6:35 pm
by jacque
dunbarx wrote: Fri May 28, 2021 2:42 pm
Is "cut" in your working dictionary? If so, just a simple omission. But either one of "cut" or "delete" ought to me a synonym of the other. "Delete" was a Hypercard native word, so I think "cut" should not have its own place, unless it does other things that delete does not.
"Cut" is in my copy of the 9.6.2 dictionary, it's the first hit when searching for "cut".
Cut and delete are different things. Cut not only removes the text or object, it also places it into the clipboard. Delete does not affect the clipboard. Cut is frequently used in an Edit menu switch statement.
Re: (Solved)How to use WordOffset to cut some text??
Posted: Sat May 29, 2021 4:26 pm
by jacque
No need to get the number of words either, you can use -1:
Code: Select all
delete word testofinale to -1 of fld "RESULT"