HC Home handlers

Jonathan Cooper joncooper at swiftdsl.com.au
Sun Mar 27 23:54:03 EST 2005


On Saturday, March 26, 2005, at 02:53  PM, Mikey wrote:

> Has anybody written handlers similar to a couple of the more popular
> ones in HC, e.g. ss, c, etc.?

Here are a few I use:

on commandKeyDown whichKey -- use like command-F in HyperCard
   if whichKey <> "E" then pass commandKeyDown
   go stack "Message Box"
   put "Find" && quote & quote into fld "Message Field" of stack 
"Message Box"
   select char 7 to 6 of fld "Message Field" of stack "Message Box"
end commandKeyDown

on tl -- toggleLock: toggles lockText of all fields
   put the defaultStack into saved_val
   set the defaultStack to the topStack
   repeat with i=1 to the number of flds
     set cursor to busy
     set lockText of fld i to not (lockText of fld i)
   end repeat
   set the defaultStack to saved_val
end tl

on filep -- put file path
   answer file "Select a file:"
   if it = empty then exit mouseUp
   put it
end filep

on folderp -- put folder path
   answer folder "Select a folder:"
   if it = empty then exit mouseUp
   put it
end folderp

on addup -- adds up column of numbers in clipboard
   put the clipboardData["text"] into temp
   set the clipboardData["text"] to columnSum(temp) -- see next handler
end addup

function columnSum str
   put 0 into total
   repeat with i=1 to the number of lines in str
     set cursor to busy
     get line i of str

     -- Note: change comma to "." in the next 2 lines if commas are used 
as decimal points:
     repeat while comma is in it
       delete char offset(comma,it) of it
     end repeat

     if it is not a number then next repeat
     add it to total
   end repeat
   return total
end columnSum

Regards,

-- 
Jonathan Cooper
Manager of Information / WWW
Art Gallery of New South Wales
http://www.artgallery.nsw.gov.au/staff/jcooper


More information about the use-livecode mailing list