put value into field row/column? Calculate total how?

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
TomiB
Posts: 23
Joined: Mon Nov 28, 2011 1:54 pm

put value into field row/column? Calculate total how?

Post by TomiB » Mon Nov 28, 2011 3:17 pm

A Hello from Tom from Switzerland !

I'm a bloody beginner.

I have two questions:

1. I want to put a word from a field into another field f.i. in line one, second cell.
How are cells adressed correctly? Usually I would think line would also be row and cell 2 would also be column 2, but it seams not to work that way.

Also it seams possible to get a value of word 2 line 3 but I can not put it into a field int word 2.
Do I need to use set itemDelimiter to tab and then adress it with a tab to get something int column 2 etc.?

put word 2 line 3 field preise card preise into line 1 word 1 field liste
put "Soft-Optima 1820, 2x100%" & return into line 1 word 2 field liste

2. If I want to add all values of a field column 1 (f.i. Lines 1 - 10) and write the total into another field namend "total"
how would that command read?

P.S.1. I can put a field name into quotationmarks "..." or it work also without the marks, what is the better way to do in general?

P.S.2. Is there a group of people where I can ask such questions as above and pay for it per question/answer, like a personal tutor?

Thank you for your apprechiated advice and your time!

Swiss-Tom

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: put value into field row/column? Calculate total how?

Post by Klaus » Mon Nov 28, 2011 3:22 pm

Grüezi Tom,

short question: are you referring to a DataGrid or a TABLE field?


Best

Klaus

P.S.
I offer LiveCode Consulting, Training & Mentoring and project assistance, see my website,
so send me a mail: klaus AT major-k.de if you are interested!

TomiB
Posts: 23
Joined: Mon Nov 28, 2011 1:54 pm

Re: put value into field row/column? Calculate total how?

Post by TomiB » Mon Nov 28, 2011 3:43 pm

Hallo Klaus

Referring to (basic) table field.

I will contact you with my next question directly, thanks.

Have a good day, Tom

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: put value into field row/column? Calculate total how?

Post by Klaus » Mon Nov 28, 2011 4:00 pm

Hi TOm,

ah, table field, OK! :D

Please let me first point you to some wonderful learning resources:
http://www.runrev.com/developers/lesson ... nferences/

Regarding your questions, please check all terms in the LiveCode dictionary to get more info:
1. a TABLE field is "just" a TAB and CR delimited text list.
So you need to address the text in it via ITEM and LINE like this:

Code: Select all

...
set itemdelimiter to TAB
## "column" 3 of line 2
put item 3 of line 2 of fld "liste" into WasAuchImmer
put WasAuchImmer into item 18 of line 32 of fld "liste"
## Always use QUOTES around names!
...
Of course you can leave out the step saving items in a variable and jut "put... into..."
I only used this for clarity!

2. Here you need to go through all lines and add the first items, but LiveCode can handle this in real-time :-)

Code: Select all

...
set itemdel to TAB
put fld "liste" into tListe
## Here this step will speed up things!
## Accessing fields in a repeat loop should be avoided whenever possible!
put 0 into tSumme
repeat with i = 1 to 10 ## or whatever lines you need
   add item 1 of line i of tListe to tSumme
end repeat
put tSumme into fld "total"
...
Best

Klaus

TomiB
Posts: 23
Joined: Mon Nov 28, 2011 1:54 pm

Re: put value into field row/column? Calculate total how?

Post by TomiB » Mon Nov 28, 2011 4:04 pm

Hallo Klaus
Thanks a heap for your advice and efforts, will go to the learning resource to get more basic knowledge.
Thank you for tutoring here, you will hear from me!
Have a nice evening,
Tom

Post Reply