Page 1 of 1

link text chunk

Posted: Mon Nov 08, 2010 11:35 pm
by Preston Shea
How do I refer to a group of words that constitute link text in a field? In a field that has link text as well words in other styles how would I say something like if the third chunk of link text in fld myField contains "website" then

Re: link text chunk

Posted: Tue Nov 09, 2010 10:21 am
by Mark
Dear Preston,

What exactly does "chunk" mean in your "the third chunk"?

Mark

Re: link text chunk

Posted: Tue Nov 09, 2010 1:05 pm
by Preston Shea
Mark wrote:Dear Preston,

What exactly does "chunk" mean in your "the third chunk"?

Mark
Good question! As I understand it, words are chunks but what do you call a group of words that has been made into a single object by "link"? For example, how would you put the number of group text items into msg? Can you get the number of links in a field?

Re: link text chunk

Posted: Tue Nov 09, 2010 1:17 pm
by Mark
Preston,

In xtalk, a chunk is a reference to a text in a field by means of the form:

char|word|line x to y of fld "Z"

for example:
char 1 to 2 of fld "Bla"
word 1 to -1 of fld "Bla"
line x to (x+1) of fld "Bla"

If you want to retrieve the text itself, you might want to use functions such as the clickText, the clickChunk, the mouseText, the selectedLine etc. Just look around in the documentation. There are very many of this type of functions.

Best regards,

Mark

Re: link text chunk

Posted: Tue Nov 09, 2010 4:46 pm
by Preston Shea
Mark wrote:Preston,

In xtalk, a chunk is a reference to a text in a field by means of the form:

char|word|line x to y of fld "Z"

for example:
char 1 to 2 of fld "Bla"
word 1 to -1 of fld "Bla"
line x to (x+1) of fld "Bla"

If you want to retrieve the text itself, you might want to use functions such as the clickText, the clickChunk, the mouseText, the selectedLine etc. Just look around in the documentation. There are very many of this type of functions.

Best regards,

Mark
I can refer to individual words with "word 5 of fld myField" how do I refer to the fifth piece of link text, i.e. the entire phrase, not the individual words in it?

Re: link text chunk

Posted: Tue Nov 09, 2010 4:59 pm
by Mark
Preston,

Of course, you can refer to single characters and words the usual way. What is "piece"?

It is still not entirely clear to me what you want to do. Just detecting linked text might be a little complicated. A possibility might be to check the style of every word in a field to see whether that style is "link", but I don't think that's what you want.

Have you read everything about "link" and related subjects in the dictionary already?

Kind regards,

Mark

Re: link text chunk

Posted: Tue Nov 09, 2010 7:34 pm
by Preston Shea
Thankk you for your patience and understanding. Yes, I have read the dictionary and the user's guide. Here's what I am trying to do:
The user clicks on a Latin word in a field of text. We get the clickText and match it up with a translating English word and show them to the user. Some times the word is part of a phrase that needs additional explaining. In that case, the phrase is joined up using "link" and matched to the additional information. All of this is working fine.

The problem comes in trying to find discrepancies between the linked words as clickText and the matching phrase in the dictionary because if there is a single char or space that doesn't match in the phrase that is clicked the search returns empty. To debug the issue I need to loop through all the words and phrases in the Latin passage. I've been able to do that for words using

for i = 1 to the number of words in fld LatinText

I understand I could also loop using chars or lines instead of words

My question: how do I loop through using link text groups? It is no good for me to go through the link text item word by word because many times a word in the link text item is used outside of that linked phrase and has a different meaning. Using the textStyle of the words doesn't seem to work because often there are two linked text groups in sequence so all the words in both groups have the style link but aren't all in the same group.

Perhaps if I could explain my problem more clearly I could figure out what I am looking for. How would you iterate through a field with regular words and group text groups in it, pick out just the link phrases a copy them into another field?

Re: link text chunk

Posted: Tue Nov 09, 2010 7:51 pm
by Mark
Hi Preston,

First of all, there is the linkClicked message. As you have read the documentation about this message, you already know that the linkClicked message has a parameter containing either the linked text or the linkText of the linked text. This should be sufficient for you.

If you really want to use a loop, you can continue the loop until you encounter a character or word that has a different textStyle:

Code: Select all

if not (the textStyle of char x of fld "ABC" contains "link") then
  exit repeat
else

Best regards,

Mark