Refering to specific cells within a table

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
cricketbird
Posts: 7
Joined: Tue May 19, 2009 8:35 am

Refering to specific cells within a table

Post by cricketbird » Sun Nov 22, 2009 8:04 pm

How do I refer to an individual cell in a table? For example, I want to say something like:

Code: Select all

put line 3 column 2 of field "mytable" into field "mytextfield"
but, there is no column keyword and I can't find anything similar.

Thanks!
CB

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Re: Refering to specific cells within a table

Post by malte » Sun Nov 22, 2009 8:14 pm

Do you use a datagrid or a table field?

Cheers,

Malte

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Refering to specific cells within a table

Post by sturgis » Sun Nov 22, 2009 8:15 pm

Use the item keyword instead. Since tables use tab as item delimiter make sure you set the delimiter in the handler where you will be addressing the item.

Code: Select all

set the itemdelimiter to tab

put "fred" into line 3 item 4 of field "myTableField"
Item delimiter is local, so theres no need to set it back to comma when done.

cricketbird
Posts: 7
Joined: Tue May 19, 2009 8:35 am

Re: Refering to specific cells within a table

Post by cricketbird » Sun Nov 22, 2009 8:16 pm

Table field. I'm using version 3.5. I just downloaded the free version of 4.0 Media, but none of these have the datagrid option.

cricketbird
Posts: 7
Joined: Tue May 19, 2009 8:35 am

Re: Refering to specific cells within a table

Post by cricketbird » Sun Nov 22, 2009 8:18 pm

Aha! The item keyword was the trick. Thank you!

Equiarch
Posts: 17
Joined: Fri May 28, 2010 8:13 pm

Re: Refering to specific cells within a table

Post by Equiarch » Fri May 28, 2010 8:54 pm

I am brand new to Rev so please excuse my ignorance.

I have the same issue of wanting the user to enter info in a field that info is multiplied by a series of ratios and the products populate cell in a table

Code: Select all

 set the itemdelimiter to tab
put  field "freqField" *(81/80) into line 2 item 3  of field "intervalTableField"
I get this error, reffering to the second line of code: button "Button": compilation error at line 3 (Chunk: bad chunk order (must be small to large)) near "item", char 46

does anyone know where I am going wrong?

Cheers,
Mario

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: Refering to specific cells within a table

Post by doc » Fri May 28, 2010 10:11 pm

No such thing as ignorance when you are just learning something new.... just new things yet unlearned. ;)

Give it a try this way:

Code: Select all

put  field "freqField" *(81/80) into item 3 of line 2 in field "intervalTableField"
HTH
-Doc-

Equiarch
Posts: 17
Joined: Fri May 28, 2010 8:13 pm

Re: Refering to specific cells within a table

Post by Equiarch » Sun May 30, 2010 7:53 pm

Thank you Doc
That was the ticket.
One more question. How do I size the cells? I can't find anything in the user manuel.

Please help
Mario

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Re: Refering to specific cells within a table

Post by Janschenkel » Mon May 31, 2010 9:18 pm

Look at the tabStops property - which you can also find in the 'Table' panel of the field property inspector.
Every entry is measured from the left of the table field, and the last width is repeated for the remainder of the columns. This may sound complicated, but it is not too hard and best explained with a few examples:
  • if you set it to "100", then all your columns will be 100 pixels wide.
  • if you set it to "100,150" then the first column will be 100 pixels wide, and the rest of the columns will be 50 pixels wide.
  • if you set it to "100,150,225" then the first column will be 100 pixels wide, the second 50 pixels, and the rest of the columns 75 pixels wide.
HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Equiarch
Posts: 17
Joined: Fri May 28, 2010 8:13 pm

Re: Refering to specific cells within a table

Post by Equiarch » Wed Jun 02, 2010 8:31 am

Thanks a million Jan!
I was wondering if anyone might know of a list of all the handlers, functions, and commands etc. because this code doesn't seem to work no matter where I put it.

Code: Select all

on start 
   put empty into card fld "freqField" 
end start 
Again please help!!!

Mario

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Refering to specific cells within a table

Post by bn » Wed Jun 02, 2010 9:19 am

Mario,
you dont specify card when referring to field since Rev does not have Card fields vs Background Fields like in Hypercard. In Rev you just refer to the field, optionally "of card "xxx" and again optionally "of stack "yyy" if you are not on that card/in that stack.

Code: Select all

on start 
   put empty into fld "freqField" 
end start
should do the trick if you are on the card the field is on.
regards
Bernd

Equiarch
Posts: 17
Joined: Fri May 28, 2010 8:13 pm

Re: Refering to specific cells within a table

Post by Equiarch » Wed Jun 02, 2010 5:10 pm

Thanks BN for your response

But I already tried that and got this error referring to the line staring with on start: card "card id 1002": compilation error at line 1 (Handler: bad handler name (may be reserved word)) near "start", char 1.
I also tried this code in the script for the field its self and for the action button and got the same error:

Code: Select all

on load 
   put empty into field "freqField" 
end load
This is why I asked for a list as It seems load or start are not the correct handlers for this.

I am trying to make it so that every time the app starts up the entry field is empty

Thanks,
Mario

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Refering to specific cells within a table

Post by bn » Wed Jun 02, 2010 5:34 pm

Mario,
sorry, I did not pay attention to that. If you want to clear a field you could do that "on opencard".
You would put:

Code: Select all

on opencard
  put empty into field "freqField"
end opencard
into the script of the card the field is on.
Than everytime you open this card = go to this card the field will be reset.
Also, if this is the first card of your stack this card, will get an opencard message when you open the stack, thus clearing the field.
You might want to look up the message hierarchy in the user guide, the pdf that comes with Rev. Accessible from the Help Menu.

If you still have trouble with this please post.
regards
Bernd

Equiarch
Posts: 17
Joined: Fri May 28, 2010 8:13 pm

Re: Refering to specific cells within a table

Post by Equiarch » Thu Jun 03, 2010 5:27 pm

bn wrote:Mario,
sorry, I did not pay attention to that. If you want to clear a field you could do that "on opencard".
You would put:

Code: Select all

on opencard
  put empty into field "freqField"
end opencard
into the script of the card the field is on.
Than everytime you open this card = go to this card the field will be reset.
Also, if this is the first card of your stack this card, will get an opencard message when you open the stack, thus clearing the field.
You might want to look up the message hierarchy in the user guide, the pdf that comes with Rev. Accessible from the Help Menu.

If you still have trouble with this please post.
regards
Bernd
Thanks Bernd

You have very helpful and are appriciated.

Peace!!!

Post Reply