Loading ...
Sorry, an error occurred while loading the content.

Re: [NRN] Re: SearchArray & SortArray

Expand Messages
  • ...Tyrell...
    ... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
    Message 1 of 1 , Mar 7, 2002
    • 0 Attachment
      >My idea for SearchArray:
      >^!SetArray %ARY%=Home;bark;dog;cat;bird;fish
      >^!Set %X%=^$SearchArray(^%ARY%,"cat")$
      >^%X%=4
      >
      >would provide a way to find the index of an array element without
      >manual entry and without needing to loop through each element to see
      >if it is the one you need.

      Who need loops ;-)

      ; - setup
      ^!Set %FIND_STR%="dog"
      ^!Set %DELIMITER%=";"
      ^!SetListDelimiter ^%DELIMITER%
      ^!SetArray %ARRAY%="Home;bark;dog;cat;bird;fish"
      ; - all in one long line
      ^!Set
      %ARY_POS%="^$StrCount("^%DELIMITER%";"^$StrCopyLeft("^%DELIMITER%^%ARRAY%";^$StrPos("^%FIND_STR%";"^%ARRAY%";0)$)$";0;0)$"
      ; - split in seperate commands
      ;^!Set %ARY_POS%=^$StrPos("^%FIND_STR%";"^%ARRAY%";0)$
      ;^!Set %ARY_POS%="^$StrCopyLeft("^%DELIMITER%^%ARRAY%";^%ARY_POS%)$"
      ;^!Set %ARY_POS%="^$StrCount(";";"^%ARY_POS%";0;0)$"
      ; - show output ... (zero) means string not found in array
      ^!INFO [L]Found "^%FIND_STR%" in Array position (^%ARY_POS%)

      Note: with large array's (array length, not size) loops will be faster. (+1500)

      Cheers
      ...Tyrell...


      _________________________________________________________
      Do You Yahoo!?
      Get your free @... address at http://mail.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.