Re: List acting like a global
Re: List acting like a global
- Subject: Re: List acting like a global
- From: JJ <email@hidden>
- Date: Wed, 05 Dec 2001 19:46:00 +0100
>
Hello,
Hello.
>
>
What's Happening?
>
So simple
>
tell application "Finder"
>
set aList to name of every item of desktop
>
end tell
-- returns a list of names
>
tell me to srListIndexer(aList)
-- returns the same list (numbered)
>
>
>
-- sr2ndListItemFromIndexOf1stList
>
set vItemWithIndex to "3 Paper Alligator"
-- new variable "vItemWithIndex" , value "3 Paper Alligator"
>
-- Capture the current delimiter for AppleScript
>
set vTids to the AppleScript's text item delimiters
>
set the AppleScript's text item delimiters to " "
>
>
set vItemIndex to (item 1 of text items of vItemWithIndex) as number
-- this is integer 3
>
-- Reset the delimiter for AppleScript to its previous call state
>
set AppleScript's text item delimiters to vTids
>
>
item vItemIndex of aList
>
--> "3 Paper Alligator"
-- translating, item 3 of aList (remember this is is a list of names)
-- Perhaps you forgot include modificate the line using the handler to:
-- set aList to (my srListIndexer(aList))
-- However, you don't need variable "vItemIndex", because it is always 3
(text item 1 of "3 Paper Alligator" using TIDs)
Expect this helps.
JJ
>
-- Should be "Paper Alligator"
>
-- What's happening?
>
>
on srListIndexer(vAnyList)
>
>
-- Capture the current delimiter for AppleScript
>
set vTids to the AppleScript's text item delimiters
>
set the AppleScript's text item delimiters to ""
>
>
repeat with vNth from 1 to count of vAnyList
>
set vListItemNth to item vNth of vAnyList
>
set item vNth of vAnyList to (vNth & " " & vListItemNth as text)
>
end repeat
>
>
-- Reset the delimiter for AppleScript to its previous call state
>
set AppleScript's text item delimiters to vTids
>
>
-- Return needed value
>
vAnyList
>
>
end srListIndexer