complex text manipulation

Jan Schenkel janschenkel at yahoo.com
Mon Nov 11 03:55:01 EST 2002


--- yves COPPE <yvescoppe at skynet.be> wrote:
> Hi,
> 
> I have a text fld named "src".
> the locktext is false
> 
> in a script I'd like to do
> 
> 1) find a line with a text
> put lineOffset("myString",fld "src") into tLine
> if tLine <> "0" then
> set the textStyle of line tLine of fld "src" to
> "link"
> end if
> 
> 2) now I'd like to click on this line to show a
> picture in another 
> stack as modal
> 
> so the script of the fld should be something like :
> 
> on mouseDown
> if the textStyle of the clickLine is "link" then
>     if the value of the clickLine is "my last
> holliday" then
>        go to cd x of stack "anotherStack" as modal
>     end if
> end if
> end mouseDown
> 
> 
> Now, the fld "src" must have his locktext turned to
> false
> 
> Is it possible ?
> -- 
> Greetings.
> 
> Yves COPPE
> 

Hi Yves,

Actually, you're almost there, though I'd do a few
things just a tad differently:

- make a button "Link" with script
on mouseUp
  -- get the text to link
  ask "Find what text to link?"
  if it is empty then exit mouseUp
  put lineOffset(it, fld "src") into tLine
  if tLine = 0 then exit mouseUp
  -- get the card to link to
  ask "To which card should this line be linked?"
  if it is empty then exit mouseUp
  put it into tLink
  -- link to the card
  set the linkText of line tLine of fld "src" to tLink
  -- now update the textStyle
  get the textStyle of line tLine of fld "src"
  switch
  case "link" is amongst the items of it
    exit mouseUp
  case it is "plain"
    set the textStyle of line tLine of fld "src" \
      to "link"
    break
  default
    set the textStyle of line tLine of fld "src" to \
    it & ",link"
    break
  end switch
end mouseUp

- have a button to lock/unlock the field
on mouseUp
  set the lockText of fld "src" to not the lockText \
    of fld "src"
end mouseUp

- set the script of the field to
on linkClicked pWhichLink
  -- pWhichLink is the linkText of the clickedChunk
  go cd pWhichLink of stack "anotherStack" as modal
end linkClicked

This should make it easier to edit/maintain the links
to the cards in the other stack.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2



More information about the Use-livecode mailing list