Raised This Month: $ Target: $400
 0% 

[ Solved ] prefix for a function.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 07-15-2012 , 09:13   [ Solved ] prefix for a function.
Reply With Quote #1

Hello everyone,
I've an other question for today

So, I see a lot's of code like that :

Code:
public bool: MyFunction( id , ... ) { /* some code */ }

Code:
public Float: MyFunction( id , ... ) { /* some code */ }

Code:
public AwesomeFuction: MyFunction( id , ... ) { /* some code */ }

So me, when i do that it do not work a lot's ...
When i compil my code they are a terrible warning

Quote:
/tmp/textgWIKME.sma(65) : warning 213: tag mismatch
So why the other code works and mine not ?

Thanks all in advance héhé
__________________
Pawn ? Useless
Aooka is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 07-15-2012 , 09:19   Re: prefix for a function.
Reply With Quote #2

and whats the data type called 'AwesomeFuction' ?
jimaway is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-15-2012 , 09:19   Re: prefix for a function.
Reply With Quote #3

The returned value must be with the same tag.
__________________
<VeCo> is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 07-15-2012 , 09:21   Re: prefix for a function.
Reply With Quote #4

Quote:
and whats the data type called 'AwesomeFuction' ?
It's just an example ^^.

Quote:
The returned value must be with the same tag.
Thanks Veco but I do not understand exactly what you want to tell me :/
__________________
Pawn ? Useless

Last edited by Aooka; 07-15-2012 at 09:21.
Aooka is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-15-2012 , 09:29   Re: prefix for a function.
Reply With Quote #5

Show your code.
__________________
<VeCo> is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-15-2012 , 09:29   Re: prefix for a function.
Reply With Quote #6

If you tag a function as a bool, you must return a bool.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 07-15-2012 , 09:37   Re: prefix for a function.
Reply With Quote #7

Oh okay.

Here it's work :
Spoiler


And here it's do not work :
Spoiler


Edit: I understand when i return an integer i do bool: fution. a float, it's Float: Fuction.
__________________
Pawn ? Useless

Last edited by Aooka; 07-15-2012 at 09:41.
Aooka is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-15-2012 , 09:39   Re: prefix for a function.
Reply With Quote #8

If you are going to tag a function, use a valid tag and then return a value of that tag. The reason why it does not work is because you are returning an untagged value where you are declaring the function as returning a tagged value


Example:
PHP Code:
public CsTeam:getTeam(id)
{
    return 
cs_get_user_team(id);

__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 07-15-2012 at 09:41.
YamiKaitou is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 07-15-2012 , 10:21   Re: prefix for a function.
Reply With Quote #9

Oh! Okay. SO it's not good to use tag like a comment/sentence/text
__________________
Pawn ? Useless
Aooka is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-15-2012 , 10:44   Re: prefix for a function.
Reply With Quote #10

Quote:
Originally Posted by Aooka View Post
Oh! Okay. SO it's not good to use tag like a comment/sentence/text
It is ok in the case where you'd want to return specific data types such as CsTeams, bool, Float, or even your defined data types. Its just like tagging a variable, but its tagging the return type. for instance......

PHP Code:
new bool:hasThing[33]

public function(
id)
{
    new 
bool:having
    having 
get_hasThing(id)
}

public 
bool:get_hasThing(id)
    return 
hasThing[id
Where as this code would not work if i were to take out the bool identifier in get_hasThing it would throw your tag mismatch warning. It is important if your functions must return specific data types.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode