Page 1 of 1

Pulling a row from a table

Posted: Wed May 13, 2015 8:37 pm
by Thalor
If I wanted to set the text of a Label field to something that is in a basic table how would I do it?

My table (TextTable) is set up as such (tab delimited)

1 Choice1
2 Choice2
3 Choice3
4 Choice4
5 Choice5


If I wanted JUST key # 4 (Choice4) how would I query the table by the key to pull the "text" part that I wanted to set the label field (labeltext) to?

Thanks in advance.

Re: Pulling a row from a table

Posted: Wed May 13, 2015 9:16 pm
by dunbarx
Hi.

The trick is to parse your data. You surely already know instinctively that to get the line of interest, you would:

Code: Select all

answer line 4 of fld "yourTableField"
But to get just the second part of line 4, you need to parse at the line level. Is your data separated by spaces? That is, are there two words in that line? If so:

Code: Select all

answer word 2 of line 4 of fld "yourTableField"
If the two parts are separated (delimited) by a tab character, as you say, you would have to go to the dictionary and look up the "itemDelimiter", play around with the examples there, and write back with the two-liner that will do what you want to.

Craig Newman

Re: Pulling a row from a table

Posted: Fri May 15, 2015 4:58 pm
by Thalor
Ok so if I wanted to get column 3 row 3 of a table

set itemdelimter to tab
put column 3 of line 3 of field "TextTable" into field "DialogText"

Would that work? Or something similar? I'm very new to this.

thanks in advance.

Re: Pulling a row from a table

Posted: Fri May 15, 2015 5:11 pm
by dunbarx
Hi.

Your thinking is correct, but not your syntax. When you set the itemDelimiter, you are talking about items, a class of chunk similar to lines, words, and characters. Each of these is delimited by specific characters, for example, lines are delimited by returns.

You would:

put item 3 of line 3 of field "TextTable" into field "DialogText"

So you need practice, which is normal.

Craig