Page 1 of 1

@uidialog / @uiradio

Posted: Wed Nov 23, 2011 10:08 am
by ramune
im trying to get the values from a table object (10 rows) to be selections in @uiradio. I understand I need a string there with options separated by a space. I tried using text.append, however when I am appending values from the table, i get like breaks in my string and I need only one like for @uiradio.

Below is the code:
!z=2
!a=1
text my_line
my_line.clear
for !a=1 to 10
table(10,1) my_categories
%category=(my_categories(!a,1))
scalar ret=@uiedit(%category, "Enter a name for your category",20)
my_categories(!a,1)=%category
my_line.append {%category}
if ret = -1 then
stop
else
next !a
endif
show my_categories
show my_line


while my_vars(!z,1)<>""
%var=my_vars(!z,1)
!selection = 1
string categoryPrompt="Choose the category"
!result = @uidialog("Caption", "Options", "Text",%var ,"Radio", !selection, categoryPrompt, my_line)
my_vars(!z,3)=!selection
if !result = -1 then
stop
else
!z=!z+1
endif
wend

Re: @uidialog / @uiradio

Posted: Wed Nov 23, 2011 10:34 am
by EViews Gareth
Your description is a little cryptic, and I can't see what you're trying to do from your program (what's my_vars?).

Perhaps what you want to do it build up the string inside your for loop? Something like:

Code: Select all

mystring = "" for !a=1 to 10 %category=(my_categories(!a,1)) scalar ret=@uiedit(%category, "Enter a name for your category",20) mystring = mystring + " " + %category my_categories(!a,1)=%category my_line.append {%category} if ret = -1 then stop else next
You will then have the space delimited string, mystring, at the end which you can feed into something else.

Re: @uidialog / @uiradio

Posted: Wed Nov 23, 2011 10:41 am
by ramune
my_vars is a table. my_categories is a table too. I need user to be able to select categories to be assigned to each row of my_vars. As a result I am making the uiradio and asking user for each my_var to select category (which they define too in the first part.)

Hope this clarifies what I am trying to do.

Thanks.

Re: @uidialog / @uiradio

Posted: Wed Nov 23, 2011 11:20 am
by ramune
Would it be easier to do such exercise using matrices? If yes, would you be able to give me some advice on how?

Cheers,

R

Re: @uidialog / @uiradio

Posted: Wed Nov 23, 2011 11:22 am
by EViews Gareth
Did you follow my advice?

Re: @uidialog / @uiradio

Posted: Thu Nov 24, 2011 4:51 am
by ramune
Yes, thank you. Needed some small tweaks in defining variables, but below is the working code:



!z=2
String mystring
table(10,1) my_categories
mystring = ""

for !a=1 to 10
%category=(my_categories(!a,1))
scalar ret=@uiedit(%category, "Enter a name for your category",20)
mystring = mystring + " " + %category
my_categories(!a,1)=%category
if ret = -1 then
stop
else
next
endif
show mystring

while my_vars(!z,1)<>""
%var=my_vars(!z,1)
!selection = 1
string categoryPrompt="Choose the category"
!result = @uidialog("Caption", "Options", "Text",%var ,"Radio", !selection, categoryPrompt, mystring)
my_vars(!z,3)=!selection
if !result = -1 then
stop
else
!z=!z+1
endif
wend