Making Copies of Lists

Date:    Mon, 13 Feb 1995 20:36:01 +0000
From:    Peter Small 
Subject: Confusion with lists
Thanks to Matt Caldwell and Roger Jones for their suggestions on saving copies of lists.

If anybody else has been confused by saving lists, they might want to put this handler in a button script and see the results in the message box.

 
on mouseUp
 
  --Create a list
  set AList to []
  put "An empty AList looks like:" && Alist & return
 
  --Fill the list up with 20 random inserts
  repeat with i = 1 to 20
    append Alist,100 +random(99)
  end repeat
 
  --Look at the list created
  put "AList is a list = " & listp(Alist)
  put "Alist looks like:" && AList & return
 
  --Look at a straight copy
  put AList into AListCopy
  put "AListCopy is a list = " & listp(AlistCopy)
  put "AlistCopy looks like:" && AListCopy  & return
 
 
  --Look at the value of AList
  put "The value of AList looks like:" && the value of AList & return
 
  put the value of Alist into AListVal
  put "AListVal is a list = " & listp(AlistVal)
  put "AlistVal looks like:" && AListVal  & return
 
  --Copy the variable containing the value
  put AListVal into AListValCopy
  put "AListValCopy is a list = " & listp(AlistValCopy)
  put "AlistValCopy looks like:" && AListValCopy & return
 
  --Now do as page 213 of manual suggests (pointed out by Matt Caldwell)
  put value(string(Alist)) into AListStringCopy
  put "AListStringCopy is a list = " & listp(AlistStringCopy)
  put "AlistStringCopy looks like:" && AListStringCopy  & return
 
  --Try out Roger Jones's sugestion
  set RogersAnswer = AList * 1
  put "RogersAnswer is a list = " & listp(RogersAnswer)
  put "RogersAnswer looks like:" && RogersAnswer  & return
 
  --See what happens when something is added to the end of AList
  append(Alist,"Changed")
  put "Alist now looks like:" && AList & return
  put "AlistCopy now looks like:" && AListCopy  & return
  put "The value of AList now looks like:" && the value of AList  & return
  put "AlistValCopy now looks like:" && AListValCopy  & return
  put "AlistStringCopy now looks like:" && AListStringCopy  & return
  put "RogersAnswer now looks like:" && RogersAnswer  & return
 
  if getLast(AlistStringCopy) <> "Changed" then
    put return & "Next time I have a problem, look at the manual before I consult the experts in DIRECT-L"
  end if
 
  if getLast(RogersAnswer) <> "Changed" then
    put return & "How, in the name of Heaven, did Roger Jones suss that one out?"
  end if
end