Basic Q: When is a string not a string?
Basic Q: When is a string not a string?
- Subject: Basic Q: When is a string not a string?
- From: Chap Harrison <email@hidden>
- Date: Sat, 24 Jan 2004 14:23:47 -0600
I'm just trying to search a list for a string and return its position
in the list. I can't find a simple verb in the docs, so I coded a
search.
The display-dialogs indicate that I'm comparing a string to a string;
yet the comparison doesn't work until I specify 'theListItem as
string'.
I just don't understand this language. Sure I have a workaround, but
I'd like to know what concept I'm unclear on here. Please help a
despairing lad ;-)
Chap
-- begin script
set myList to {"Chap", "Mimi", "Reid", "Ann", "Toby"}
-- get "Mimi" is in myList
set k to searchList(myList, "Mimi")
on searchList(theList, theString)
local i
set i to 1
repeat with theListItem in theList
display dialog (i as string) & " test " & theListItem & " against " &
theString & "
Class of theListItem is " & class of theListItem & "
Class of theString is " & class of theString
if theListItem is theString then -- recoding as 'if theListItem as
string is theString then' works!?
return i
else
set i to i + 1
end if
end repeat
return 0
end searchList
k -- 0 (should be 2)
-- end script
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.