(Solved)How to use WordOffset to cut some text??
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 203
- Joined: Mon Oct 31, 2011 9:36 pm
- Location: Italy
- Contact:
(Solved)How to use WordOffset to cut some text??
Hi.. I need to delete e delimiter some text with wordoffset command....can you help me with some examples codes please??'Thaks a lot ...Lestroso
Last edited by Fasasoftware on Fri May 28, 2021 3:48 pm, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: How to use WordOffset to cut some text??
Hi,
What about this ?
Best
Jean-Marc
What about this ?
Code: Select all
on delOneWord pWord
put wordoffset(pWord,fld 1) into tNumW
delete word tNumW of fld 1 -- works !
-- cut word tNumW of fld 1 -- also works !
end delOneWord
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9587
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to use WordOffset to cut some text??
Jean-Marc.
"Cut" ????
Craig
"Cut" ????
Craig
-
- Posts: 203
- Joined: Mon Oct 31, 2011 9:36 pm
- Location: Italy
- Contact:
Re: How to use WordOffset to cut some text??
Code: Select all
on mouseUp
delOneWord
end mouseUp
on delOneWord pWord
put wordoffset(pWord,fld "RESULT") into tNumW
delete word tNumW of fld "RESULT" -- works !
-- cut word tNumW of fld 1 -- also works !
end delOneWord
-
- VIP Livecode Opensource Backer
- Posts: 9587
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to use WordOffset to cut some text??
Lestroso.
What Jean-Marc said, but a simple example of the wordOffset function will only find the first word in some text. There are ways to find the others, but what do you need for your stack?
Also, did you really mean "delimiter"? Or just a word in some text? A delimiter might allow other methods to work.
Craig
What Jean-Marc said, but a simple example of the wordOffset function will only find the first word in some text. There are ways to find the others, but what do you need for your stack?
Also, did you really mean "delimiter"? Or just a word in some text? A delimiter might allow other methods to work.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: How to use WordOffset to cut some text??
Craig
Lestroso
delOneWord need a param. Your pWord is empty
Jean-Marc
Yes, I was surprised dictionary dont tell something about it"Cut" ????
Lestroso
delOneWord need a param. Your pWord is empty
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9587
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to use WordOffset to cut some text??
Hi.
If you read the code, you will see that the variable "pWord" is never defined. Jean-Marc was giving an example of how the function works. He does not know which word anyone is actually interested in.
You can make this yours by adding:
But why use two handlers when one will do?
Craig
If you read the code, you will see that the variable "pWord" is never defined. Jean-Marc was giving an example of how the function works. He does not know which word anyone is actually interested in.
You can make this yours by adding:
Code: Select all
on mouseUp
delOneWord "yourWordHere"
end mouseUp
Craig
-
- Posts: 203
- Joined: Mon Oct 31, 2011 9:36 pm
- Location: Italy
- Contact:
Re: How to use WordOffset to cut some text??
First of all, i want to thank you every body for yours efforts..
Ok.. in simple words...
I need to delete in a field.. from the word 1 to a word defined by me in a variable...and cut it..simple this... but i don't remember if i should use wordoffset or not...Thanks a lot again..Lestroso
Ok.. in simple words...
I need to delete in a field.. from the word 1 to a word defined by me in a variable...and cut it..simple this... but i don't remember if i should use wordoffset or not...Thanks a lot again..Lestroso
-
- VIP Livecode Opensource Backer
- Posts: 9587
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to use WordOffset to cut some text??
Jean-Marc.
It is not even a synonym of "delete".
Craig
It is not even a synonym of "delete".
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9587
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to use WordOffset to cut some text??
Fasasoftware
Check out "wordOffset" in the dictionary. You will find that you can set "words to skip", so as not to be limited to only the first occurrence. So if you wanted to delete the fourth occurrence, that extra parameter gives you the tools to do so.
Craig
Check out "wordOffset" in the dictionary. You will find that you can set "words to skip", so as not to be limited to only the first occurrence. So if you wanted to delete the fourth occurrence, that extra parameter gives you the tools to do so.
Craig
-
- Posts: 203
- Joined: Mon Oct 31, 2011 9:36 pm
- Location: Italy
- Contact:
Re: How to use WordOffset to cut some text??
Dear friends,
I need to delete in a field.. from the word 1 to a word defined by me in a variable...Can you help me with some fresh code???.Thanks a lot again..Lestroso
I need to delete in a field.. from the word 1 to a word defined by me in a variable...Can you help me with some fresh code???.Thanks a lot again..Lestroso
-
- VIP Livecode Opensource Backer
- Posts: 9587
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to use WordOffset to cut some text??
Hi.
Put some text into field 1. In a button script:
Enter the word you want to delete up to.
More importantly, do you see how this works? Write back if you do not see it clearly, please.
Craig
Put some text into field 1. In a button script:
Code: Select all
on mouseUp
ask "Delete up to which word?"
delete word 1 to wordOffset(it,fld 1) of fld 1
end mouseUp
More importantly, do you see how this works? Write back if you do not see it clearly, please.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9587
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to use WordOffset to cut some text??
Bogs.
I know you still work in v.1.0.
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.
Craig
I know you still work in v.1.0.
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.
Craig
Re: How to use WordOffset to cut some text??
Lestroso, I'm not sure exactly where the previous examples are failing to be understood, but no matter which version of offset you use, the usage basically goes like this -
The attached stack is commented and uses lineOffset to pick lines from the source of the website you linked to in another thread as the base example.
You can either type or copy / paste a word (or words) from the source into the word 1 and 2 fields. When you hit "cmdDel" you will be prompted whether or not to delete the lines shown (line numbers in the "Start" and "End" line fields, the actual text shown on the right). If you press "Yes", well, I hope you get the idea.
@Craig -
I was actually setting up this example in 6.7.9 (*which I know is one of your absolute FAV versions !!*) when I cracked the dictionary and looked up cut for you
I do not think cut should be a direct synonym of delete, when you delete something, you are just getting rid of it, when you cut something, you have the option of putting it either back, or someplace else.
- You pick an event handler, or create a handler or function where you want the offset to be fired from.
- You put the {character, word, or multiple words} you want to be the offset into a variable.
- You then setup the offset statement.
The attached stack is commented and uses lineOffset to pick lines from the source of the website you linked to in another thread as the base example.
You can either type or copy / paste a word (or words) from the source into the word 1 and 2 fields. When you hit "cmdDel" you will be prompted whether or not to delete the lines shown (line numbers in the "Start" and "End" line fields, the actual text shown on the right). If you press "Yes", well, I hope you get the idea.
@Craig -
I was actually setting up this example in 6.7.9 (*which I know is one of your absolute FAV versions !!*) when I cracked the dictionary and looked up cut for you
I do not think cut should be a direct synonym of delete, when you delete something, you are just getting rid of it, when you cut something, you have the option of putting it either back, or someplace else.