I have a word list (taked from a folder name) and I want to test for
a spoecific word in it.
...
Here's what I have so far but the last line errors....
on run
set aFolder to choose folder
CheckDNum(aFolder)
end run
on CheckDNum(aFolder)
tell application "Finder"
set item_name to the name of aFolder as text
set AppleScript's text item delimiters to " "
set AllWords to every word of item_name as list
log AllWords
set Dnum to every word of AllWords whose character 1
is "D"
end tell
end CheckDNum
The last line errors because you asked a list for it's words. Strings
have words, lists have items. Try this:
on run
tell application "Finder" to set aFolder to name of (choose folder)
CheckDNum(aFolder)
end run
on CheckDNum(aFolder)
set Dnum to {}
repeat with chunk in (every word of aFolder)
considering case -- we are looking for capitals
if item 1 of chunk is "D" then
if length of chunk is in {5, 6} then -- is it the right length?
try
(text 2 thru -1 of chunk) * 1 -- is the remainder a number?
set end of Dnum to chunk as Unicode text
end try
end if
end if
end considering
end repeat
return Dnum
end CheckDNum
Malcolm Fitzgerald
FOR YOUR COMPUTER Customised software built to your specifications.
Using Macs? Automate your workflow with AppleScript. FOR YOU Computer
training, software installation + upgrades, computer setups. IN TIMES
OF NEED Troubleshooting, maintenance + repairs.