At 5:27 PM -0700 9/5/00, Kerry Thompson wrote:
>This should be simple, but I'm getting tangled up in the dot 
>syntax--and maybe in multidimensional arrays, too. It's been a long 
>week this month.
>
>I want to display a list of words, chosen from several lists. 
>Ideally, I'd like to do something like:
>
>wordList = masterList[n]
>repeat with i = 1 to wordList.count
>   put wordList.aWord[i]
>end repeat
>
>The line I am looking to convert to a list looks like this:
>"Start;Lingo;C;Pascal"
>
>Currently I have this code to create the list:
>the itemDelimiter = ";"
>repeat for i = 1 to numLines
>    theText = masterText.line[i].item[1] --I know this works
>    if theText = "Start" then
>       addProp(gWordList, #listStart, [:]
>       repeat with j = 2 to masterList.line[i].item.count
>          addProp(gWordList, #aWord, masterList.line[i].item[j]
>       end repeat
>    end if
>end repeat
>
>I know I'm not building the list right--I think I want a list 
>something like this:
>
>[#listStart: [#aWord: "Lingo", #aWord: "C", #aWord: "Pascal"], 
>#listStart [#aWord: "Apple", #aWord, "Dell", #aWord, "Gateway"]]
>

Kerry,

Maybe I'm mising something here, but why are you using property lists 
at all?  I don't see any advantage of using the the extra and 
confusingly duplicated symbols.  Instead, I would suggest using a 
structure which is a linear list of linear lists, like this:

[["Lingo", "C", "Pascal", ["Apple", "Dell", "Gateway"], [etc.]]

Your parsing becomes more like this (untested):

gWordList = []
the itemDelimiter = ;
repeat for i = 1 to numLines
   theText = masterText.line[i].item[i]
   if theText = "Start" then
       -- Using Bhakti's suggestion
       tempList = []
       nItems = masterList.line[i].item.count
       repeat with j = 2 to nItems
           append(tempList, masterList.line[i].item[j])
       end repeat
       -- now add the temp list into your global list
       append(gWordList, tempList)
    end if
end repeat

Then to display a particular list, do this:

wordList = gWordList[n]
nItems = wordList.count()
repeat with i = 1 to nItems
    put wordList[i]
end

Irv
-- 
Lingo / Director / Shockwave development for all occasions
            (We even do weddings and Bar Mitzvahs!)
   See our kid's CD-Rom's at:  http://www.furrypants.com

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to