Page 1 of 1

evaluating if an attribute exists using @isobject

Posted: Fri Apr 26, 2019 11:15 am
by BT454
Hi!
I'm wondering if it's possible to check if a specific attribute exists for a group of data series using the @isobject function.
Thinking something like the code below, but my job is crashing saying that "some_attribute" is not defined. I'm sure my syntax is off.
Any help is appreciated!
Thanks,
Bob

string series_list = ""
for %x {%string_of_series}
!x = @isobject({%x}.attr(some_attribute))
if !x = = 0 then
string series_list = {series_list} + %x + " "
else
endif
next

Re: evaluating if an attribute exists using @isobject

Posted: Fri Apr 26, 2019 11:22 am
by EViews Gareth

Code: Select all

string series_list = "" for %x {%string_of_series} %xx = {%x}.attr(some_attribute) if @len(%xx)=0 then string series_list = {series_list} + %x + " " else endif next

Re: evaluating if an attribute exists using @isobject

Posted: Fri Apr 26, 2019 11:46 am
by BT454
Thanks!
I'm receiving an error message saying the named attribute (in this case UNIT) is not defined.
Here is the exact code, and I've attached the workfile. I'm wondering if it's a case sensitive issue (i.e. I have the attribute defined as "Unit" in the code and the workfile, but it appears the program is looking for "UNIT")?
Thanks again for the help!

group g *
%vars = g.@members
string series_list = ""
for %x {%vars}
%xx = {%x}.attr(Unit)
if @len(%xx)=0 then
string series_list = {series_list} + %x + " "
else
endif
next

Re: evaluating if an attribute exists using @isobject

Posted: Fri Apr 26, 2019 11:55 am
by EViews Gareth

Code: Select all

group g * %vars = g.@members string series_list = "" for %x {%vars} %xx = {%x}.@attr("Unit") if @len(%xx)=0 then series_list = series_list + %x + " " else endif next