-- Loren Mork, Seattle, Wa, Lmork@aol.com
-- v 1.0 1998
-- SetCursor is a handler that sets the cursor of sprite for
-- any number of sprites or sprite ranges - it uses lists
-- and integers, seperated by commas, to designate the sprites.
-- The first value or list must contain the cursor you wish to use.
-- Input the first parameter / argument either as the
-- single number of a Director internal cursor, such as 260
-- (for the hand icon), or as a list of two numbers representing
-- membernums of a one bit image and it's mask [ 16, 17],
-- ie: a custom cursor (see below)
-- Examples:
-- setCusor 260
-- shows where to place a single number -260- for
-- the cursor number (in this case the internal hand cursor).
-- NOTE:there must also be designated sprites to affect
-- or nothing will happen.(see below)
-- see bottom of this handler for a listing of internal cursors
-- setCursor [16,17]
-- shows where and how to place
-- the list of members used for a custom cursor
-- NOTE:there must also be designated sprites to affect
-- or nothing will happen.(see below)
-- After the cursor has been designated, put in the sprites
-- you wish the cursor to affect
-- as either single integers seperated by commas, or
-- by lists containg two numbers
-- ie the bottom of the sprite range you want selected,
-- and the top of that sprite range
-- or by a combination of both
-- there are no restrictions on the number of parameters / arguments.
-- setCursor 260, 3, 9, [23,35], 67, 90, [106,112]
-- the line above sets,to cursor 260 (the internal hand cursor), sprites 3,9,23-35,67,90,106-112
-- setCursor [16,17], [1,25], 36,[42,80],[105,116], 120
-- the line above sets,to a custom cursor using members [16,17],
-- sprites 1- 25, 36, 42-80, 105-116,120
-- Note that after setting the inital cursor number, you can list in as many sprites
-- or sprite ranges as you wish-
-- there is no preformatted restrictions on these parameters / arguments
-- but the first parameter / argument always has to designate the cursor
-- get the number of parameters / arguments that come after the handler name
-- and put in a variable
set tParamCount = the paramCount
-- defensive check to see if less than 2 parameters
if tParamcount < 2 then exit
-- the first parameter is always the cursor.
-- it can be passed as a list, ie [spritenum,spritenum] or [34,35]
-- or passed as a number contained on the tInternalCursorList
set tCursor = param(1)
-- list of internally available cursors
set tInternalCursorList = [0, 200,254,256,257,258,259,260,272,280,281,282,283,284,285,286,290,291,292,293,300,301,302,303,304]
-- defensive check to see if the first parameter is a list that has more than 2 numbers in it
-- if it does then exit
if listp(tCursor) = 1 then
if count(tCursor) > 2 then exit
end if
-- defensive check to see if the first parameter is a list
-- if it is not then check to see if it is on tCursorList
-- if not on either then exit - it is not a valid cursor number
-- after this filter, the cursor of any sprite can be set to tCursor.
-- tCursor is ready-to-go.
-- Note - other cursor numbers can be added to tInternalList if neccesary
if listp (tCursor) = 0 then
if getPos (tInternalCursorList, tCursor) = 0 then exit
end if
-- start the repeat loop at the second parameter in the list
-- because number one is always the cursor as a list or integer
-- loop through all other parameters
repeat with currentparam = 2 to tParamCount
put param(currentparam) into tTempParam
if not listp(tTempParam) then
-- defensive check
-- if it is not a list it must be a single sprite number
-- if it is zero, then ignore it and get next number
if tTempParam = 0 then next repeat
set the cursor of sprite tTempParam = tCursor
next repeat
-- get the next value from the list
else
-- must be a list
-- get the two numbers off of the list
set tStartSprite = getat (tTempParam , 1)
set tEndSprite = getat (tTempParam , 2)
end if
if tStartSprite > tEndSprite then
-- defensive check to see if the largest number came first
repeat with tSprite = tStartSprite down to tEndSprite
-- must be in wrong order, so adjust
set the cursor of sprite tSprite = tCursor
end repeat
else
-- correct order
repeat with tSprite = tStartSprite to tEndSprite
set the cursor of sprite tSprite = tCursor
end repeat