How to figure the type of a variable?

Andre Garzia soapdog at mac.com
Sun Jul 11 20:57:57 EDT 2004


oh damn... my match expressions were wrong... replace all this code 
with nested ifs... it's working fine.

cheers
andre


On Jul 11, 2004, at 9:49 PM, Andre Garzia wrote:

> Hi folks,
>
> I am trying to build a routine to check what is the type of a variable 
> so that I can generate XML-RPC Parameters. I am using a switch 
> structure I pasted below. The problem is, when executing the handler 
> like:  xmlRPCCall "http://someurl", "somemethod", "andre", 1, 
> "10/06/98"  all parameters evaluate to string even the date and the 
> number... the snipet that deals with strings is the "default" part of 
> the switch, I thought, if it ain't a date, bool, int or float then it 
> must be a string, but, everything turns to be a string... any clues?
>
> PS: yes, I am using those nice functions made by Sarah :D
>
>
> if the paramCount > 2 then
>     addNewXMLElement tTreeID, "/methodCall", "params", ""
>     repeat with x = 3 to the paramCount
>       put x - 2 into tNum
>
>       switch (param(x))
>       case (param(x) is a integer)
>         addNewXMLElement tTreeID, "/methodCall/params/", "param", ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]", "tNum", tNum), "value", 
> ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]/value", "tNum", tNum), 
> "int", param(x)
>         break
>
>       case (param(x) is a number)
>          addNewXMLElement tTreeID, "/methodCall/params/", "param", ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]", "tNum", tNum), "value", 
> ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]/value", "tNum", tNum), 
> "float", param(x)
>         break
>
>       case (param(x) is a boolean)
>         addNewXMLElement tTreeID, "/methodCall/params/", "param", ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]", "tNum", tNum), "value", 
> ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]/value", "tNum", tNum), 
> "boolean", param(x)
>         break
>
>       case (param(x) is a date)
>         addNewXMLElement tTreeID, "/methodCall/params/", "param", ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]", "tNum", tNum), "value", 
> ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]/value", "tNum", tNum), 
> "date", param(x)
>         break
>
>       default
>         addNewXMLElement tTreeID, "/methodCall/params/", "param", ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]", "tNum", tNum), "value", 
> ""
>         addNewXMLElement tTreeID, 
> replaceText("/methodCall/params/param[tNum]/value", "tNum", tNum), 
> "string", param(x)
>         break
>
>
>
>
>
>
>         break
>       end switch
>     end repeat
>   end if
>
>
> -- 
> Andre Alves Garzia ð 2004
> Soap Dog Studios - BRAZIL
> http://studio.soapdog.org
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
-- 
Andre Alves Garzia ð 2004 ð BRAZIL
http://studio.soapdog.org



More information about the use-livecode mailing list