Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Basic question regarding lists

Hi all,

I'm facing myself with a basic question regarding lists: how can I return a predefined list item into a string? Can I do it with unverified perl? I've searched the docs, but from what I found - LISTVALUE and LISTLABEL - won't suit my needs.

Thank you,
asked May 28, 2012 by João Fernandes Bronze (2,040 points)
retagged Sep 13, 2012 by Walter Williams

1 Answer

0 votes
I'm a bit unclear on what you are trying to do?

There is a function called Label that displays the label text rather than the label value (the function Value displays this). This is how it is used in SSI Script and Perl ...

SSIScript - Label(QuestionName)
Perl -  LABEL("QuestionName")
Comment - Returns the label that is associated with the answer to a single select response type question.

ListLabel allows you to select a code from any given position within the list and display it accordingly.
answered May 28, 2012 by Paul Moon Platinum (98,670 points)

I forgot to write "value" ("(...) a predefined list item *value* into a string"). What I need is to access an item within a predefined list.

In Perl, if a predefined list was handled like an array, it would be something like this:

my $tmpString = "";

$tmpString = $RandomQuestions[0];
With Perl, you can use something like this in a free format hidden question ...

<input name="HdQ1_STRING" type="hidden" value="
Begin Unverified Perl

 my $Q1_string="0";
if (VALUE("Q1")==1)

elsif (VALUE("Q1")==2)

elsif (VALUE("Q1")==3)


return $Q1_string;
End Unverified

This would give you a string type answer.

You may check out some help at http://progzoo.net/wiki/Perl:Convert_a_Number_to_a_String?
Thanks for all the help, Paul. What I'm looking for is what I've mentioned, but in the context of building a constructed list. For that reason, I don't think I can use the VALUE function there, or can I? Since I'm building a list, I guess I can't. Am I wrong?
I have a hunch you might be over-thinking things.  Could you perhaps add a comment and tell us exactly what you are doing/what you wish to achieve in the survey?
Send us through an example of what you are trying to do. Use question numbers/names if you have to. The list functions and/or Perl will help us sort the problem out no doubt.

Go to the help and look up "List Building" and "List Functions". The help is very good with explaining all aspects of these topics. That's how I taught myself.
Hi all,

Sorry for the late, late reply. Meanwhile, I changed my approach. I needed to change the default layout for the .dat file SSI Web generates, and I was trying to do it in the source, i.e., inside SSI Web, by manipulating lists. But it was easy to understand that it wasn't the best way to do it.

Nevertheless, I'm treating the file now in Excel, which is the most correct approach, I guess.