Page 1 of 1

Table Field Cells

Posted: Wed Dec 09, 2009 12:55 am
by lohill
Is there a better way than the following to get the contents of a specific cell in a table field?
on mouseUp
ask "What cell do you want to see? (row,column)"
if the number of items of it <> 2 then
beep
exit mouseup
end if
put item 1 of it into x
put item 2 of it into y
If char 1 of x = "(" then put empty into char 1 of x
if last char of y = ")" then put empty into last char of y
set the itemDelimiter to tab
answer item y of line x of field "Grid1"
end mouseUp

Also, if I may ask another question - Is there a way to regulate the widths of separate columns in a table field?

Thanks,
Larry

Re: Table Field Cells

Posted: Wed Dec 09, 2009 2:41 am
by sturgis
It will probably be easier to do what you want using a substack as a custom dialog. Look up Modal in the dictionary.

The column widths in a table field are determined by the tabstops.

Setting the tabstops to 100,100,300 will make the first 2 columns 100 pixels wide, then the rest of the columns to 300.

IE

Code: Select all

set the tabstops of field "fieldname" to 40,50,60,80,200

Re: Table Field Cells

Posted: Wed Dec 09, 2009 4:17 pm
by lohill
sturgis,

Thanks for the 'set the tabstops' command. It does exactly what I want. I'll have to do some more studying to figure out your Modal solution for referencing cells. I was hoping that there was some simple way of addressing a specific in a table field like 'cell(5,2)' or 'cell(B3)' rather than having to deal with a container of tab delimited lines. As you can tell I am a beginner and being able to use the dictionary effectively often means you need to know the right word to look uo. I have a lot to learn.

Larry

Re: Table Field Cells

Posted: Wed Dec 09, 2009 4:36 pm
by sturgis
The are good reasons to use a substack in modal mode as your input dialog. Its easier to control how things are input for example limiting input to numbers. You can make it look just how you want. If you would rather use ask, it would probably be easier to ask twice, once for row, once for column so you don't have to mess with splitting up the data.

As for doing something like cell(5,2) you can setup something like this.

Code: Select all

command getCell x y tField
   set the itemdelimiter to tab
   put item x line y of field tField
end getCell
This just puts the contents of the specified cell into the message box of course so you would have to better define what you wanted done with the data.
Put it in the message path, then you can pass your cell coords and the field you want to

To use this simple thing you can do this.

Code: Select all

on mouseUp
   getCell 1,1,"theField" -- calls the getCell command and passes to it the item number, row number and name of the field
end mouseUp

lohill wrote:sturgis,

Thanks for the 'set the tabstops' command. It does exactly what I want. I'll have to do some more studying to figure out your Modal solution for referencing cells. I was hoping that there was some simple way of addressing a specific in a table field like 'cell(5,2)' or 'cell(B3)' rather than having to deal with a container of tab delimited lines. As you can tell I am a beginner and being able to use the dictionary effectively often means you need to know the right word to look uo. I have a lot to learn.

Larry

Re: Table Field Cells

Posted: Wed Dec 09, 2009 4:54 pm
by lohill
WOW!
Thanks again - Larry