Use strings for scalar

For questions regarding programming in the EViews programming language.

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

dubs
Posts: 3
Joined: Fri Mar 03, 2023 6:31 am

Use strings for scalar

Postby dubs » Mon Mar 13, 2023 12:25 am

Hello,

I'm a trying to use strings (which contain number) as scalar with the @val function. It works fine with string objects but does not work with string variables.
So

Code: Select all

string str = "1"
scalar i = @val(str)

works fine and i has the value 1.
But if I do

Code: Select all

%str = "1"
scalar i = @val(%str)

i takes the value NA. I guess it is not a normal behaviour as it is almost the same example as in the documentation (the only difference is that I affect the value to a scalar instead of a control variable to be able to check its value).
Do you have any idea why this occurs?

Thank you,

David

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

Re: Use strings for scalar

Postby EViews Gareth » Mon Mar 13, 2023 8:40 am

Should work.
2023-03-13_084040.png
2023-03-13_084040.png (36.39 KiB) Viewed 2612 times
Follow us on Twitter @IHSEViews

dubs
Posts: 3
Joined: Fri Mar 03, 2023 6:31 am

Re: Use strings for scalar

Postby dubs » Mon Mar 13, 2023 9:17 am

It does not for me...
eviews.png
eviews.png (38.65 KiB) Viewed 2611 times

Could it be related to the version of Eviews (I use 12) or an option?

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

Re: Use strings for scalar

Postby EViews Gareth » Mon Mar 13, 2023 9:43 am

You need to use a program.
Follow us on Twitter @IHSEViews

dubs
Posts: 3
Joined: Fri Mar 03, 2023 6:31 am

Re: Use strings for scalar

Postby dubs » Tue Mar 21, 2023 3:39 am

Thank you, indeed that makes sense


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 28 guests