Arrays and Lists

Jim Ault JimAultWins at yahoo.com
Tue Oct 18 13:31:46 EDT 2005


Sorry about missing the point.  I saw a couple bugs in your original and
thought that was the problem.

In this case you may want to create an array of array names created on the
fly.
I am going to use the term 'moniker'
step 1 - determine the array name to use for data storage (eg sArr1, sArr2)
the 's' stands for 'symbol'
step 2 - determine the array to use to store "sArr1", "sArr2" (eg globalArr)
the 'g' stands for 'global'
step 3 - add "sArr1" to the 'globalArr'  >the keys of globalArr = "sArr1",
"sArr2"

In this case, you might want to consider using the 'do'
--------------------- copy from here
on mouseup
  put quote into q
  put 1 into x
  put "cows give milk" into val  --value of the element
  do ("put "&q&val&q&" into globalArr["&q&("sArr"&x)&q&"]")
  --
  --now the "cows give milk" would be in globalArr["sArr1"]
  answer globalArr["sArr1"]

  put 2 into x
  put "goats do too" into val
  do ("put "&q&val&q&" into globalArr["&q&("sArr"&x)&q&"]")
  --now the "goats do too" would be in globalArr["sArr2"]
  answer globalArr["sArr2"]

  --the list of sArr instances would be
  answer the keys of globalArr
  answer the number of lines in ( the keys of globalArr)
  
end mouseup
--------------------------------- end copy from here

Jim Ault
LasVegas




On 10/18/05 5:45 AM, "David Burgun" <dburgun at dsl.pipex.com> wrote:

> HI,
> 
> Thanks for the Sample, but I I think you may have misunderstood what
> I was trying to ask. I have got array's working just fine, but what I
> need is a dynamic list of arrays. I basically have a variable number
> of symbol tables (which are represented as Arrays), which is the
> reason I called them Array1, Array2, ....,  etc., since knowing their
> name is not helpful, since they don't have one, well not one that is
> defined at compile time anyway.
> 
> I have some Global Functions that maintain a list of Symbol table names, as
> so:
> NewSymbolTable theSymbolTableName   <-- Adds theSymbolTableName to
> the Global Symbol Table List.
> DeleteSymbolTableViaIndex theIndex  <-- Deletes the Symbol theIndex
> from the  Global Symbol Table List
> GetSymbolTableNameViaIndex theIndex <-- Returns the Symbol Table Name
> at the theIndex of the Global Symbol Table List
> GetSymbolTableCount <-- Returns the number of Symbol Tables currently
> in the  Global Symbol Table List.
> 
> Now what I would like to do is to be able to hold a list of arrays,
> and have functions:
> 
> GetSymbolTableArrayViaIndex theIndex <-- Returns an Array which
> represents the Symbol for the theIndex of the Global Symbol Table List
> SetSymbolTableArrayViaIndex theIndex <-- Set the Symbol Table for
> theIndex of the Global Symbol Table List.
> 
> I will also add functions to do the same via the Name of the Symbol
> Table in the  Global Symbol Table List.
> 
> 
> The problem is I don't know how to represent a list of Array's in
> TranScript/RunRev, so any pointers on that would be greatly
> appreciated.
> 
> All the Best
> Dave
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list