AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Tag of an actual argument passed to function (https://forums.alliedmods.net/showthread.php?t=133732)

SnoW 07-28-2010 08:25

Tag of an actual argument passed to function
 
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 */


All times are GMT -4. The time now is 00:07.

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