Detect variable type
Hi friends,
Is there any way to detect a variable type like this : new Float:myfloat,myinteger,mystring[] switch(vartype(myfloat)) { case 0: //integer case 1: //float case 2: //string } |
Re: Detect variable type
The main problem how to pass a var into a function which can be a float, string or integer. I don't think it's possible.
Otherwise, to see if it's a string, see if the last case is null-terminated, for float, convert into string and see if you see '.', else it's an integer. :mrgreen: Anyway, I'm interested why would you need something like that. Can you provide more informations ? Maybe there another way to do what you want at the end. |
Re: Detect variable type
If you want to get the type of a var, that make no sense.
since pawn only have one type called cell, block of memory a tag decide which type a var is. same bits with different tags have different value. |
Re: Detect variable type
Not sure if this works,but i've seen it in Pawn docs:
Code:
public plugin_init() |
Re: Detect variable type
Hello all !
@Arkshine, it's more difficult : i dont want to test if the data contain a float value, but i want to test if target variable is a float or not, with this test, it's possible to make a str_to_num or str_to_float in destination variable. Some function like format accept many various type of variable, i think it is also possible with Pawn code. @danielkza Ok i will test now ! Thanks ! EDIT : @danielkza : I LOVE YOU ! THAT EXCATLY WHAT I WANT !!!!! (But you can't make the test "tagof Float", it's not a problem). Karma for you ! |
| All times are GMT -4. The time now is 05:33. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.