(Solved)How to use WordOffset to cut some text??

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

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: How to use WordOffset to cut some text??

Post by Fasasoftware » Fri May 28, 2021 3:48 pm

I thank you so much to every body but i have had success with my piece of code.....Thanks a lot again!!!! Lestroso :D

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


Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: (Solved)How to use WordOffset to cut some text??

Post by Klaus » Fri May 28, 2021 4:08 pm

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)

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: (Solved)How to use WordOffset to cut some text??

Post by Fasasoftware » Fri May 28, 2021 5:37 pm

THANKS KLAUS!!!thanks a lot for your comment....Best regards, Lestroso :D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to use WordOffset to cut some text??

Post by jacque » Fri May 28, 2021 6:35 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: (Solved)How to use WordOffset to cut some text??

Post by jacque » Sat May 29, 2021 4:26 pm

No need to get the number of words either, you can use -1:

Code: Select all

delete word testofinale to -1 of fld "RESULT"
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”