I have a dataset that involves both questions and answers that I want populated into a data grid with 2 columns in it: 1 for the question, and 1 for the score.
I am trying to figure out the best way to display the information in the data grid and have run into a slight snag.
Some of the questions have commas in them: i.e "How many times has sir lancelot felt emotional, depressed, or tired?"
How can i insert the text correctly and still keep the commas in the questions? When i populate it by replacing the commas with tabs, I get segments of questions all over the place. Do i need to take the comments out, or is there a way to keep the commas in the final output?
Thanks in advance for your help.
populating field contents into a table
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: populating field contents into a table
Hm, why are you replacing the TABs?
This will do:
...
## COMMAS will not get lost:
put fld "question1" & TAB & fld "answer1" into tData
set the dgtext of grp "your dg here" to tData
...
But maybe I misunderstand your question.
This will do:
...
## COMMAS will not get lost:
put fld "question1" & TAB & fld "answer1" into tData
set the dgtext of grp "your dg here" to tData
...
But maybe I misunderstand your question.
Re: populating field contents into a table
First of all, let me say thank you for your comment and suggestion! I really do appreciate it.
As far as my initial question, i should have been more clear. I was initially trying to populate a datagrid with data from a field separated by commas, line by line. The commas in the questions kept screwing up my output to the datagrid as i replaced the commas with Tabs to place into the table.
However, In playing with your method, it seems simpler. So i wrote up something different. Unfortunately, i am only able to populate one line using the following script:
What am i doing wrong that i cannot get the rest of the questions and scores to populate?
Again, thank you very much in advance!
As far as my initial question, i should have been more clear. I was initially trying to populate a datagrid with data from a field separated by commas, line by line. The commas in the questions kept screwing up my output to the datagrid as i replaced the commas with Tabs to place into the table.
However, In playing with your method, it seems simpler. So i wrote up something different. Unfortunately, i am only able to populate one line using the following script:
Code: Select all
On openCard
put 1 into newCount
repeat while newCount <10 # there are only 9 questions
put qArray[newCount]["question"] & TAB & qArray[newCount]["iscore"] into theData
add 1 to newCount
end repeat
set the dgText of group "output" of stack "surveyss" to theData
put "Total Score: " & qTab into field "total" of stack "surveyss"
end openCard
Again, thank you very much in advance!
Re: populating field contents into a table
Hi p0ntif,
well, you are overwriting the data in every repeat loop, so only the last answer/question pair will appear in the datagrid!
...
put qArray[newCount]["question"] & TAB & qArray[newCount]["iscore"] INTO theData
...
Do this:
Best
Klaus
well, you are overwriting the data in every repeat loop, so only the last answer/question pair will appear in the datagrid!

...
put qArray[newCount]["question"] & TAB & qArray[newCount]["iscore"] INTO theData
...
Do this:
Code: Select all
On openCard
put empty into theData
repeat with newCount = 1 to 9 # there are only 9 questions
put qArray[newCount]["question"] & TAB & qArray[newCount]["iscore"] & CR AFTER theData
end repeat
## Delete trailing CR:
delete char -1 of theData
set the dgText of group "output" of stack "surveyss" to theData
put "Total Score: " & qTab into field "total" of stack "surveyss"
end openCard
Klaus
Re: populating field contents into a table
Klaus, you are the best! Thanks!

