Re: adding to a list selected from a list of lists
Re: adding to a list selected from a list of lists
- Subject: Re: adding to a list selected from a list of lists
- From: has <email@hidden>
- Date: Wed, 20 Feb 2002 12:39:13 +0000
paul withey wrote:
>
property rock_cheese : {"string of text1", "string of text2 "}
>
>
This is so that the additions to the list made by the user are retained
>
over runs of the applet
Tip: Data stored in properties is lost if the script is later recompiled.
If your user-entered data is valuable, consider storing it in a separate
file instead.
>
as you correctly worked out i would like to present the user with a
>
list of lists they have created and my default
>
lists not the actual contents of the lists...
There's various ways you could tackle this problem - the script below
shows one approach.
HTH
has
======================================================================
property keyList : {"list1", "list2"}
property theLists : {{"1", "2", "3"}, {"4", "5", "6"}}
on getList(theKey)
repeat with x from 1 to count keyList
if keyList's item x is theKey then return theLists's item x
end repeat
error "Key not found."
end getList
on chooseList()
try
choose from list keyList with prompt "Choose the list to add
[NO-BREAK]the value to:"
if result is false then
error "User cancelled." number -128
else
result's first item
end if
on error number 2002
error "Cannot choose a list as there aren't any."
end try
end chooseList
--
on addNewList()
set listName to text returned of (display dialog "Name of new
[NO-BREAK]list:" default answer "")
if keyList contains listName then error "That list already exists."
set keyList's end to listName
set theLists's end to {}
end addNewList
on addValueToList()
set theValue to text returned of (display dialog "The value to
[NO-BREAK]add:" default answer "")
set theList to getList(chooseList())
set theList's end to theValue
end addValueToList
--TEST
try
repeat
button returned of (display dialog "Name of new list:" buttons
[NO-BREAK]{"Add new list", "Cancel", "Add value to list"})
if result is "Add new list" then
addNewList()
else
addValueToList()
end if
end repeat
on error number -128
end try
{keyList:keyList, theLists:theLists}
======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[
http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]
_______________________________________________
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.