Thank you Bertrand, this helps me a lot!

It seems that comparing to zero is a bit tricky. I only get results with

string s; // or string s="lolcat";
_typeof(s) == _typeof(0);

Is there a neater way to do this?

Signature Met vriendelijke groet / With kind regards / mit besten Grüßen,




Coen Schalkwijk
Software Engineer

coen.schalkwijk@rtl.nl

coen@rtlinteractief.nl

+31 (0)35 671 8915


On 13-1-2011 15:21, Bertrand LUPART wrote:
Another problem is that 'string s;' or 'string s=0;' evaluate to 'int' when using %t and 'zero_type()' doesn't help either.

Not a problem for pike but for any other language using the generated XML.
As a workaround, have you considered using typeof()/_typeof() ?

----8<----8<----8<----
string s; string t=0; string u=""; string v="foo";
zero_type(s);
(1) Result: 0
zero_type(t);
(2) Result: 0
zero_type(u);
(3) Result: 0
zero_type(v);
(4) Result: 0
typeof(s);
(5) Result: string
typeof(t);
(6) Result: string
typeof(u);
(7) Result: string
typeof(v);
(8) Result: string
_typeof(s);
(9) Result: zero
_typeof(t);
(10) Result: zero
_typeof(u);
(11) Result: string
_typeof(v);
(12) Result: string
---->8---->8---->8----