Hi there,
this a newbie qustion, but i can`t figure it out!
If a list like this
myList={“first”,“”,“third”,“”,“”,“sixth”} and so on.
How can I delete the empty items in myList.
Result should e like this:
myList={“first”,“third”,“sixth”}
Thanks in adance!
Maybe fastest routines, but this will do the job:
set myList to {"first", "", "third", "", "", "sixth"}
deleteXFromList("", myList)
to deleteXFromList(x, thisList)
set finalList to {}
repeat with i in thisList
set i to i's contents
if i is not equal to x then set finalList's end to i
end repeat
return finalList
end deleteXFromList
Hey JJ,
thanks for your quick response - and sorry for my delayed answer.
Your script works perfectly in the Script Editor, but I want to run this Script inside a tell … end tell statement - and suddenly it won`t work anymore.
e.g.
tell Filemaker
activate
run your script
end tell
any suggestions?
thanks
mr. funky
Try:
my deleteXFromList(“”, myList)
Anyway, what does it mean “suddenly it won’t work anymore”? Any error message, are you running it from an applet, from a scriptmaker script?..
Hi JJ,
i run this Skript inside the Scripteditor. I try to copy a list of words from quark to filemaker. I copy the words in quark and these words are stored inside the list “myList”. In Filemaker I want to copy them into a specific field. So this list should be without the collected “” empty items.
your script works but when I but the Script inside the
tell “filemaker”
activate
set myList to {“first”, “”, “third”, “”, “”, “sixth”}
deleteXFromList(“”, myList)
to deleteXFromList(x, thisList)
set finalList to {}
repeat with i in thisList
set i to i’s contents
if i is not equal to x then set finalList’s end to i
end repeat
return finalList
end deleteXFromList
end tell
the error message
Exspected “end” or “end tell” but found “to”<
appears.
What i`m doing wrong?
thx
Oh, I see…
deleteXFromList is a handler (a subroutine), and it can’t be located within a tell block. This structure should compile and work OK:
tell application "QuarkXPress"
--> do whatever to get myList
end
--> delete empty items
set myList to {"first", "", "third", "", "", "sixth"}
set myList to deleteXFromList("", myList)
--> and store the results into the same variable myList
tell application "FileMaker Pro"
--> do whatever with myList
end tell
--> this handler will execute whenever it is called
to deleteXFromList(x, thisList)
set finalList to {}
repeat with i in thisList
set i to i's contents
if i is not equal to x then set finalList's end to i
end repeat
return finalList
end deleteXFromList
Thanks a lot JJ - this will do it for me!
Thanks a lot JJ -
this will do it for me!
Thanks a lot JJ -
this will do it for me!