GetClassName() dont work with IndexOf()

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

GetClassName() dont work with IndexOf()

Post by Apeirogon »

Version 3.3.2

Work

Code: Select all

class qwerty : actor
{
	string asdf;
states
{
spawn:
	tnt1 q 100 {
	asdf = self.getClassName();
	console.printf("%I", asdf.indexOf("we") );
	}
	loop;
}
}
Dont work

Code: Select all

class qwerty : actor
{
states
{
spawn:
	tnt1 q 100 {
	console.printf("%I", self.getClassName().indexOf("we") );//Invalid expression on left hand side of IndexOf
	}
	loop;
}
}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: GetClassName() dont work with IndexOf()

Post by Graf Zahl »

GetClassName returns a name, not a string, and a name does not have a member function called 'indexOf'. You have to explicitly cast it to a string first, otherwise the function cannot be found.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: GetClassName() dont work with IndexOf()

Post by Apeirogon »

I think getclassname() returns already a string, so...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: GetClassName() dont work with IndexOf()

Post by Graf Zahl »

No, it returns a name. Internally that is a lightweight index into a case insensitive string table. It will be implicitly converted into a string when assigned to one - but since it is a different type it just cannot be used as invoker of a string method.
Post Reply

Return to “Closed Bugs [GZDoom]”