assign by reference (arrays)?

Rob Cozens rcozens at pon.net
Thu Mar 21 14:27:00 EST 2002


>My
>first attempt was the equivalent of
>
>
>   on doit msgdata
>     put empty into aUseInfo
>     put empty into aImproveInfo
>     repeat for each line msgrec in msgdata
>         put item 1 of msgrec into msgID
>         put item 2 of msgrec into msgReplyID
>         put item 3 of msgrec into msgList
>         switch msgList
>         case "use"
>             put aUseInfo into aInfo
>             break
>         case "improve"
>             put aImproveInfo into aInfo
>             break
>         end switch
>         get aInfo[rID]
>         if it = empty then
>             put 1 && mID into aInfo[rID]
>         else
>             add 1 to word 1 of it
>             put it && mID into aInfo[rID]
>         end if
>    end repeat
>   end doit
>
>But that doesn't work, because 'aInfo' is each time a fresh copy of either
>the 'aUseInfo' array, or the 'aImproveInfo' array.

Try this, Ben,

   on doit msgdata
     put empty into aUseInfo
     put empty into aImproveInfo
     repeat for each line msgrec in msgdata
         put item 1 of msgrec into msgID
         put item 2 of msgrec into msgReplyID
         put item 3 of msgrec into msgList
         switch msgList
         case "use"
             put aUseInfo into aInfo
             put true into fromUse
             break
         case "improve"
             put aImproveInfo into aInfo
             put false into fromUse
            break
         end switch
         get aInfo[msgReplyID]
         if it = empty then put 1 && msgID into aInfo[msgReplyID]
         else
             add 1 to word 1 of it
             put it && msgID into aInfo[msgReplyID]
         end if
         if fromUse then put aInfo into aUseInfo else put aInfo into 
aImproveInfo
    end repeat
   end doit


-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list