@uidialog / @uiradio

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

ramune
Posts: 4
Joined: Wed Nov 23, 2011 9:51 am

@uidialog / @uiradio

Postby ramune » Wed Nov 23, 2011 10:08 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: @uidialog / @uiradio

Postby EViews Gareth » Wed Nov 23, 2011 10:34 am

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.

ramune
Posts: 4
Joined: Wed Nov 23, 2011 9:51 am

Re: @uidialog / @uiradio

Postby ramune » Wed Nov 23, 2011 10:41 am

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.

ramune
Posts: 4
Joined: Wed Nov 23, 2011 9:51 am

Re: @uidialog / @uiradio

Postby ramune » Wed Nov 23, 2011 11:20 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: @uidialog / @uiradio

Postby EViews Gareth » Wed Nov 23, 2011 11:22 am

Did you follow my advice?

ramune
Posts: 4
Joined: Wed Nov 23, 2011 9:51 am

Re: @uidialog / @uiradio

Postby ramune » Thu Nov 24, 2011 4:51 am

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests