Referencing cells by column and row name

T. R. Ponn alptex2 at orwell.net
Fri Jan 2 16:24:22 EST 2004


Mark,

How about something like this...not polished, but maybe a start  Put 
this in the stack script:

global stateData
on openStack
  -- The following can be placed in a hidden field, property or variable.
  -- Also, it can be "hard-coded" as shown or read in from a text file.
  put "State"&tab&"Population"&tab&"Area"&tab&"Birth"&tab&"Capitol"&cr&\
      "Ohio"&tab&"11,421,267"&tab&"44,828 Sq 
Mi"&tab&"1803"&tab&"Columbus"&cr&\
      "Florida"&tab&"16,713,149"&tab&"65,758 Sq 
Mi"&tab&"1845"&tab&"Tallahassee"&cr&\
      "Minnesota"&tab&"5,019,720"&tab&"86,943 Sq 
Mi"&tab&"1858"&tab&"Saint Paul" into stateData
end openStack

And this in a field script:

global stateData
on rawkeyUp k
  if k=61 or k=65493 then
    set the itemDelimiter to tab
    put " "&(item (itemOffset(word 1 of me,line 1 of stateData)) of\
        line (lineOffset(word 3 of me,stateData)) of stateData) after me
    select line 1 of me
  end if
  pass rawKeyUp
end rawkeyUp

Now type "Population of Ohio =" into the field and the result will 
appear thusly: "Population of Ohio = 11,421,267".
"Capitol of Florida =" will appear as: "Capitol of Florida = Tallahassee"
...and so on...

Best Regards,

Tim Ponn



Mark Powell wrote:

>Say I have 50 lines of tab-delimited data.  Each line represents one of the 50 U.S. states.  Each item within a line corresponds to some kind of data (population, area, etc.)  Is there any way using Rev's built-in commands to write something akin to 
>
>get item "Population" of line "Colorado"
>
>where Population and Colorado are not variables, but 'column' and 'row' names.  Is it possible to establish names in this way and retrieve data similarly to above?
>
>Appreciate any and all suggestions
>
>Mark Powell
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>  
>




More information about the use-livecode mailing list