
'==========================
'TYPE AWARENESS AND CASTING
'==========================

  type node string name, float x,y,z

  function f(any*v, string typ) as string
  '======================================
  '
  'IDENTIFY AND CAST THE VARIABLE TYPE
  '
  string vs
  '
  if typ="long" then
    vs=(long) v
  elseif typ="double"
    vs=(double) v
  elseif typ="bstring" then
    vs=(bstring) v
  elseif typ="string" then
    vs=(string) @v '@' DYNAMIC STRING
  elseif typ="node" then
    node n at @v   '@' HIGHER TYPES
    return n.name ":  " n.x "," n.y "," n.z
  else
    return "Unsupported type:  " typ
    exit function
  end if
  '
  return vs
  '
  end function

'TESTS:
'======

long    a=12345
double  d=1234.5
string  s="Hello!"
bstring b="GoodBye"
node n={"Here!", 1.5,2.5,3.5}

print f a,typeof a
print f d,typeof d
print f s,typeof s
print f b,typeof b
print f n,typeof n

frees b
