Raised This Month: $ Target: $400
 0% 

Tag of an actual argument passed to function


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-28-2010 , 08:25   Tag of an actual argument passed to function
Reply With Quote #1

Quote:
Originally Posted by http://compuphase.com/pawn/Pawn_Language_Guide.pdf
You can check the tag of the actual argument by adding an extra argument to the function, and set its default value to be the “tagof” of the argument in question. Similar to the sizeof operator, the tagof operator has a special meaning when it is applied in a default value of a function argument: the expression is evaluated at the point of the function call, instead of at the function definition. This means that the “default value” of the function argument is the actual tag of the parameter passed to the function.
I'd like a functionality above but it doesn't seem to be working. I was thinking if that's a feature only in newer versions of Pawn but didn't find anything in logs. It doesn't seem that the expression would be evaluated at the point of function definition either because the value of the variable holding the tag id keeps being zero even you would change the tag of the function argument.

Code:
#include < amxmodx > public plugin_init( ) {     new No, any: Any, test: Test, test2: Test2;         PrintTag( No );     PrintTag( Any );     PrintTag( Test );     PrintTag( Test2 );         server_print( "No: %i, Any: %i, Test: %i, Test2: %i", tagof( No ), tagof( Any ), tagof( Test ), tagof( Test2 ) ); } PrintTag( Var, Tag = tagof( Var ) ) {     #pragma unused Var         server_print( "Tag: %i", Tag ); } /* Code print: Tag: 0 Tag: 0 Tag: 0 Tag: 0 No: 0, Any: 2, Test: 13, Test2: 14 */
SnoW is offline
Send a message via MSN to SnoW
 



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 00:07.


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