Page 1 of 1
data from query into scrolling list field
Posted: Sun Jun 29, 2014 6:24 pm
by francof
Hi again with another question.
as in subject, I'm trying to show item 1 of all the lines of data from query into a scrolling list field.
the data back from query are 2 items, column "DOMANDA" and column "RISPOSTA"
I only am able to show all the 2 items so:
Code: Select all
set ItemDel to TAB
put tRsTrovaDom into field "txtDomTrovate"
in this way:
Code: Select all
set ItemDel to TAB
put item 1 of tRsTrovaDom into field "txtDomTrovate"
I've back only item 1 (column DOMANDA) but, only of the first line...
another try:
Code: Select all
repeat for each line i in tRsTrovaDom
put item 1 of line i of tRsTrovaDom into field "txtDomTrovate" -- item 1 contiene la domanda
end repeat
stops with error:
"card "crdDomAperte": execution error at line 93 (Chunk: error in range start expression), char 1"
thanks for help
franco
Re: data from query into scrolling list field
Posted: Sun Jun 29, 2014 6:35 pm
by bangkok
francof wrote:
Code: Select all
repeat for each line i in tRsTrovaDom
put item 1 of line i of tRsTrovaDom into field "txtDomTrovate" -- item 1 contiene la domanda
end repeat
stops with error:
franco
You mixed up repeat for each and repeat with
Code: Select all
repeat for each line tLine in tRsTrovaDom
put item 1 of tLine after field "txtDomTrovate"
end repeat
Or
Code: Select all
repeat with i = 1 to the number of lines of tRsTrovaDom
put item 1 of line i of tRsTrovaDom after field "txtDomTrovate"
end repeat
By the way, watchout with "into" for a field within a loop.... It doesn't make sense (the content of the field will be replaced at each iteration of the loop).
Re: data from query into scrolling list field
Posted: Sun Jun 29, 2014 7:49 pm
by phaworth
Should be:
put item 1 of line i of tRsTrovaDom & return after field "txtDomTrovate"
... assuming each item is to be on a separate line.
Pete
Re: data from query into scrolling list field
Posted: Sun Jun 29, 2014 8:45 pm
by francof
Hi bangkok, Pete
I solved merging your answer both...
Code: Select all
set ItemDel to TAB
repeat for each line tLine in tRsTrovaDom
put item 1 of tLine & return after field "txtDomTrovate"
end repeat
just one thing wrong:
I think to have in the column "RISPOSTA",in the table of the DB, some data divided in 2 or more lines. so I've a part of "RISPOSTA"(which should be ITEM 2) like ITEM 1, and show in the field "txtDomTrovate" reserved to the item1 "DOMANDE"
sorry I've forgot to clarify.... (DOMANDE mean questions, and RISPOSTA mean answer)
bangkok wrote:
...............
By the way, watchout with "into" for a field within a loop.... It doesn't make sense (the content of the field will be replaced at each iteration of the loop).
and how can I do in a better way?
in my case I haven't a lot of iterations but, in case of hundreds or thousand of them..... could be not the best.
ciao and thanks all
franco
Re: data from query into scrolling list field
Posted: Wed Jul 09, 2014 11:51 am
by MaxV
Here the problem is how you obtain the data from the DB, because your answers contain
return char.
Example, if you dB is:
Code: Select all
|DOMANDA | RISPOSTA |
|--------+----------|
|1+1? | 2 |
|--------+----------|
|names? |Ale and |
| |Max |
|--------+----------|
when you retrieve data with this code:
Code: Select all
put revDataFromQuery(tab,return,connID,tSQL) into tRecords
You obtain:
You have to change the line separator char, for example with:
Code: Select all
put revDataFromQuery("+++","%%%",connID,tSQL) into tRecords
you get:
This way you can separate values without problem with
return char.
Re: data from query into scrolling list field
Posted: Wed Jul 09, 2014 11:57 am
by Klaus
Hi Max,
looks like this has been solved in another thread:
http://forums.livecode.com/viewtopic.php?f=12&t=20946
Best
Klaus