ID's for linked text?

Jim Ault JimAultWins at yahoo.com
Thu May 11 11:32:49 EDT 2006


On 5/11/06 8:07 AM, "Derek Larsen" <dll392 at gmail.com> wrote:

> I have a text field that has specific paragraphs setup as linked. I'd like
> to find a dynamic way to find out which one of those paragraphs the user
> clicked on without having to know the content of the paragraph.
> Is there any kind of ID or number associated with each link? I haven't been
> able to find anything useful in the documentation.
> 
> Any insight would be appreciated.
> 
There is no ID that I know of, but you could make one.
You could make the paragraph the key of an array and the element would be
the number/code you use to know which paragraph is chosen.

Is your paragraph defined by CR's?
Are they long or short text runs?
Is the entire paragraph the link?

You could use an array or custom properties of the stack.
Your paragraphs will become the keys of a single array or each paragraph
will become a custom property of the stack.  In each case, the paragraphs
must be unique for all characters, otherwise, two identical paragraphs will
end up being the same key of an array or custom property.

--array method
global gParagraphArray
set the itemdel to cr
put item 1 of fld readingMaterial into keyTxt
put (the short id of this card &"c"&1) into gParagraphArray[keyTxt]

put item 2 of fld readingMaterial into keyTxt
put (the short id of this card &"c"&2) into gParagraphArray[keyTxt]

thus a loop is born......
repeat with x = 1 to the number of items in fld readingMaterial
   put item x of fld readingMaterial into keyTxt
   put (the short id of this card &"c"&x) into gParagraphArray[keyTxt]
end repeat

set the itemdel to comma

--------------------------------------
custom property method
set the itemdel to cr
repeat with x = 1 to the number of items in fld readingMaterial
   put item x of fld readingMaterial into keyTxt
   set the keyTxt of this stack to (the short id of this card &"c"&x)
end repeat
---------------------
Now you need to write a couple routines to handle changes you make to the
text, thus the stored text becomes obsolete

clear global gParagraphArray
repeat with c = 1 to the number of cards
--add to the global array here
end repeat
---or----
set the customproperties of this stack to empty
repeat with c = 1 to the number of cards
--add to the customproperties here
end repeat

This will double the size of your stack, since all of the text will be
stored twice.   There are many other variations, but you get the gist.
Hope this gives you some ideas


Jim Ault
Las Vegas






More information about the use-livecode mailing list