Script: Select a range of chars in revScriptEditor

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pderks
Posts: 58
Joined: Sat May 14, 2011 4:25 pm
Location: Krefeld • Deutschland

Script: Select a range of chars in revScriptEditor

Post by pderks » Wed Apr 05, 2017 12:40 pm

After an operation "Find Strings in Scripts" the field "FoundList" (autohilite & listbehavior) contains a list of founds, e.g.:
field id 1018 of card id 1002 of stack "/A/LiveCode 8.1.3 ƒ/Edit ƒ/pdA.livecode" (tab) 14,31

LineClick in this field sends "RetrieveInScript", which opens the script editor and selects and colors the given range of characters.

Code: Select all

on RetrieveInScript
   set the ItemDelimiter to tab
   get the HilitedText of fld "FoundList"
   put item 1 of it into ObjDesc
   put item 2 of it into CharRange
   set the ItemDelimiter to comma
   put item 1 of CharRange into CharFirst
   put item 2 of Range into CharLast
   edit the Script of ObjDesc -- 2 times
   edit the script of ObjDesc
   select last char of fld "Script" of window "revNewScriptEditor 1" -- else last visible line is selected & colored
   select char CharFirst to CharLast of fld "Script" of window "revNewScriptEditor 1"
   set the TextColor of char CharFirst to CharLast of fld "Script" of window "revNewScriptEditor 1" to „red“
end RetrieveInScript
I hope this contribution may be helpful …

Peter

Post Reply

Return to “Talking LiveCode”