• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
calling handler with named parameters fails from script?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

calling handler with named parameters fails from script?


  • Subject: calling handler with named parameters fails from script?
  • From: Timothy Bates <email@hidden>
  • Date: Sun, 01 Apr 2001 03:38:07 +1000

hi here,

Any clue as to why these first two forms fail to compile:

set newList to bob's getASample of 2 from {1,2,3} without Replacement
set newList to getASample of 2 from {1,2,3} without Replacement of bob

but this succeeds?

tell bob
set sampledList to getASample of 2 from {1,2,3} without Replacement
end tell

Recasting the handler as nonnamed allows the first two forms to compile fine


i.e,
set newList to getASample(2,{1,2,3},false) of bob
works just fine

PS: the script is copied below

script bob
to getASample of itemCount from theList given Replacement:replaceing
if itemCount > length of theList then
error "getNElements: cannot ask for more items than exist"
end if
set chosenItems to {}
if replaceing then
repeat with n from 1 to itemCount
set end of chosenItems to some item of theList
end repeat
else
repeat with n from 1 to itemCount
set x to random number from 1 to count of theList
set end of chosenItems to item x of theList
set stimList to removeItem of theList at x
end repeat
end if
return chosenItems
end getASample



on removeItem of theList at x --, theList)
-- removes any item from a list
set x to (x as number)
if x < 1 then return theList
set numItems to count of items in theList
if numItems is 1 then return {}
if x > numItems then return theList
if x = 1 then
set newList to (items 2 thru -1 of theList)
else if x = numItems then
set newList to (items 1 thru -2 of theList)
else
set newList to (items 1 thru (x - 1) of theList) & (items (x +
1) thru -1 of theList)
end if
return newList
end removeItem


to makeASparseList of nItems from theList given minimumRepeat:min
set outList to {}
set last4 to {}
repeat while (count of outList) < nItems
set tryThis to (some item of theList)
if tryThis is not in last4 then
set outList to outList & tryThis
set last4 to last4 & tryThis
if (count of last4) > min then set last4 to items -min thru
-1 of last4
end if
end repeat
return outList
end makeASparseList

end script

Dr Timothy Bates <mailto:email@hidden>
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University
Ph 61 (2) 9850 8623
Fx 61 (2) 9850 6059


  • Prev by Date: is it possible to load a script library with a creation handler
  • Next by Date: Re: is it possible to load a script library with a creation handler
  • Previous by thread: is it possible to load a script library with a creation handler
  • Next by thread: Re: calling handler with named parameters fails from script?
  • Index(es):
    • Date
    • Thread