[gme-users] How SetAttribute may fail

Zoltan Molnar zolmol at isis.vanderbilt.edu
Fri Jan 6 12:02:22 CST 2006


Just a sidenote


Since the singature of setAttribute is like
bool SetAttribute( Cstring& attrname, Cstring& newValue)
It should not compile if used as
SetAttribute( "attr1", "value1");
[because a const char * can't be converted to CString& (which is an
in-out parameter)!!!]


Instead, variables must be used for both:
Cstring an = "attr1";
Cstring v = "value1";
SetAttribute( an, v);

Beware, though the compiler lets you use this form [emits only a
warning]:
SetAttribute( an, "value1")
It is still incorrect to use this form [and it doesn't set the
attribute], because the second parameter is converted to bool (as the
warning indicates, the best match is SetAttribute( Cstring& attr, bool
value) ), because of the same reason: "value1" a const char * can't be
converted to a reference [Cstring&].


Br, Zoli

> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu 
> [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf 
> Of Jane Lin
> Sent: Friday, January 06, 2006 9:55 AM
> To: gme-users
> Subject: Re: [gme-users] How SetAttribute may fail
> 
> 
> Thanks. But the reason on my side is the attribute name, 
> which I just found 
> out. The attribute name shown in the model open in GME is a 
> prompt name, not 
> exactly the name defined in its meta-model. When I wrote the 
> interpreter, I 
> should have used the attribute name defined in its meta-model 
> instead of its 
> prompt name.
> 
> It took me some time to debug this because the meta-model is 
> defined by 
> others and BON didn't give very helpful error message.
> 
> Jane
> --------------------------------------------------------------
> -------------------
> Yuehua (Jane) Lin
> Department of Computer and Information Sciences
> University of Alabama at Birmingham
> liny at cis.uab.edu
> http://www.cis.uab.edu/liny
> 
> 
> ----- Original Message ----- 
> From: "Cong Zhang" <czhanga at gmail.com>
> To: "A list for GME users to share thoughts and discuss bugs 
> and fixes." 
> <gme-users at list.isis.vanderbilt.edu>
> Sent: Thursday, January 05, 2006 6:15 PM
> Subject: Re: [gme-users] How SetAttribute may fail
> 
> 
> > Try the code like in the following:(suppose you want to set an 
> > attribute called "rate")
> >
> > CString attrname("rate");
> > model->SetAttribute(attrname, "something");
> >
> > It seems that I failed if I used
> > model->SetAttribute("rate", "something");
> >
> > On 1/5/06, Jane Lin <liny at cis.uab.edu> wrote:
> >> Hi,
> >>
> >> In my GME plug-in component written with BON1, I tried to 
> called the 
> >> SetAttribute method of the CBuilderObject class to set a 
> value to an 
> >> attribute of a model, which type is string. But it failed. I could 
> >> see the return result of this method call was false. What 
> does this 
> >> mean possibly?
> >> How can I debug this?
> >>
> >> Thanks,
> >>
> >> Jane
> >> 
> ---------------------------------------------------------------------
> >> ------------
> >> Yuehua (Jane) Lin
> >> Department of Computer and Information Sciences
> >> University of Alabama at Birmingham
> >> liny at cis.uab.edu
> >> http://www.cis.uab.edu/liny
> >>
> >>
> >> _______________________________________________
> >> gme-users mailing list
> >> gme-users at list.isis.vanderbilt.edu
> >> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> >>
> >>
> >>
> > _______________________________________________
> > gme-users mailing list
> > gme-users at list.isis.vanderbilt.edu
> > http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> 
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> 


More information about the gme-users mailing list