Secure getAt

From Director Online Wiki
Jump to: navigation, search
--/******
--* SECURE GET AT
--* Doesn't throw error, return Void.
--****
--* @Param  : 'aList' <PropList> or <LinearList>
--* @Param  : 'x'     <Symbol>   or <Integer> 
--* @Return : ''      <Any>
--* @Note   : You could also overload the getAt() method and use bracket access.
--*           Check the result with Void Predicate.
--***/
on mSecureGetAt( aList, x )
--
if listP(aList) then
  return( [Void, aList[max( min( abs(x) + (x = 0) OR Not(IntegerP(x)), aList.count ), aList.findPos(x) )]]\
[max( (IntegerP(x) AND (x > 0) AND (x <= aList.count)), (SymbolP(x) AND ilk(alist, #PropList) AND aList.findPos(x)) ) + 1 ] )
end if
--
return( Void )
end
--*/