Hello,
I'm struggling with the following problem, days of searching the internet and livecode fora haven't brought me any closer to a solution.
I want to select a line a table field by finding a matching name and the store a number of associated parameters in variables.
The table field contains the name in the first column, the number of parameters in the second column and the actual parameters in the rest of the columns.
Sounds rather uncomplicated but I really haven't got a clue how to do it.
Any help is greatly appreciated!
newbie question about finding elements in table fields
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 2
- Joined: Sun Oct 31, 2010 11:24 pm
Re: newbie question about finding elements in table fields
Hi Gern,
welcome to the forum.
a table field has the format of Lines = return delimited and on a line the items of the table are tab delimited.
suppose you have a tablefield in field 1. Your first column = the text before the first tab has the name of the line.
you have a second field, make a button, set the script of the button to:this puts line 3 into field 2
for the rest you would have to explain a little your data structure. Do you know in advance what the columns are? Do you have the variables ready to take up data. Do you have to create the variables on the fly (confusing and difficult).
I would store the master index = column 2 in a variable and the rest of the actual values in another variable
. Leave them in the tab delimited format and you can always access them as item x of myActualValuesVariable
Dont forget that the itemdelimiter has to be set to tab in that case.
I attached my teststack. This might make things clearer.
I hope this gets you started.
regards
Bernd
welcome to the forum.
a table field has the format of Lines = return delimited and on a line the items of the table are tab delimited.
suppose you have a tablefield in field 1. Your first column = the text before the first tab has the name of the line.
lets suppose that the names of the rows of the tablefield = item 1 of a line are unique.abd 2 15 29
def 3 11 30 23
ghi 4 42 44 46 48
jkl 3 18 19 20
you have a second field, make a button, set the script of the button to:
Code: Select all
on mouseUp
put field 1 into tData
set the itemDelimiter to tab
repeat with i = 1 to the number of lines of tData
if item 1 of line i of tData is "ghi" then
put line i of tData into tFoundLine
exit repeat
end if
end repeat
put tFoundLine into field 2
end mouseUp
the variable tFoundline contains row 3. Important is the fact that you have to set the itemdelimiter to tab. The default itemdelimiter is comma.ghi 4 42 44 46 48
for the rest you would have to explain a little your data structure. Do you know in advance what the columns are? Do you have the variables ready to take up data. Do you have to create the variables on the fly (confusing and difficult).
I would store the master index = column 2 in a variable and the rest of the actual values in another variable
. Leave them in the tab delimited format and you can always access them as item x of myActualValuesVariable
Dont forget that the itemdelimiter has to be set to tab in that case.
I attached my teststack. This might make things clearer.
I hope this gets you started.
regards
Bernd
- Attachments
-
- dataItems for gernhuijberts.livecode.zip
- (1.79 KiB) Downloaded 200 times
Re: newbie question about finding elements in table fields
Other solution with ITEMOFFSET
- Attachments
-
- ITEMOFFSET.zip
- (953 Bytes) Downloaded 191 times
-
- Livecode Opensource Backer
- Posts: 2
- Joined: Sun Oct 31, 2010 11:24 pm
Re: newbie question about finding elements in table fields
Thank you Bernd,
That makes it a lot clearer, I was actually looking for functions or commands that would do the trick but this is very straight forward!
Thank you again
Gern
That makes it a lot clearer, I was actually looking for functions or commands that would do the trick but this is very straight forward!
Thank you again
Gern
Re: newbie question about finding elements in table fields
Gern,
you are welcome. If you have questions please don't hesitate to ask here in the forum.
bangkok's solution is an advanced concept. I tried to keep it simple so you get the basics of chunk operations in Livecode.
Chunks in Livecode are very powerful and fun to use once you get the idea behind it.
regards
Bernd
you are welcome. If you have questions please don't hesitate to ask here in the forum.
bangkok's solution is an advanced concept. I tried to keep it simple so you get the basics of chunk operations in Livecode.
Chunks in Livecode are very powerful and fun to use once you get the idea behind it.
regards
Bernd