Hi all,

It's getting late, so I'm probably missing something obvious.

I'm trying to write a set of generic handlers that fetches and replaces data 
from a global variable that contains its data in a table (or array, if they're 
the same thing - not sure of the nomenclature here!). The reason I'm not 
working with variables directly is because in the future, I might want to swap 
saved files with a database. Plus, it's easier to save a few of these master 
variables to a file and clean out them out when the user loads in a new file.

Anyways, when the variable hasn't been created, the handler works: it creates 
the new global variable and puts the required data into it. Lovely.

Problem is, when I then try to use the handler to add a second line or replace 
theElements of the first, it creates an entirely new global varible with a name 
of the data I stuck in the correct global variable.

Any help gratefully received!


Steve

--

on writeToTable whichTable, whichKey, whichCase, theElements
  do "global " & whichTable
  do "put " & whichTable && "into tempTable"

  set itemDelimiter to numToChar(28)

  put lineOffset (whichKey & "_" & whichCase, tempTable) into theLine
  
  if theLine> 0 then
    put theElements into item 4 of line theLine of tempTable
  else
    put whichKey&"_"&whichCase into line (number of lines of tempTable) + 1 of 
tempTable
    put whichKey into item 2 of last line of tempTable
    put whichCase into item 3 of last line of tempTable
    put theElements into item 4 of last line of tempTable
  end if
  
  do "put tempTable into" && whichTable
end writeToTable
_________________________________________________________________
Share what Santa brought you
https://www.mycooluncool.com_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to