• 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
Basic Q: When is a string not a string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Panther: Quark 6 to PostScript Page Range Possible?
      • From: Jason Bourque <email@hidden>
    • Re: Basic Q: When is a string not a string?
      • From: Emmanuel <email@hidden>
    • Re: Basic Q: When is a string not a string?
      • From: Walter Ian Kaye <email@hidden>
  • Prev by Date: Re: what is error -1753?
  • Next by Date: Re: Basic Q: When is a string not a string?
  • Previous by thread: Re: Filemaker 'whose' clause broken?
  • Next by thread: Re: Basic Q: When is a string not a string?
  • Index(es):
    • Date
    • Thread