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


  function f(any*v, string typ)
  '============================
  '
  'IDENTIFY AND CAST THE VARIABLE TYPE
  '
  string vs
  sys a
  '
  if typ="long" then
    vs=(long) v
  elseif typ="double"
    vs=(double) v
  elseif typ="string" then
    vs=(string) @v '@' DYNAMIC STRING ODDITY
  elseif typ="bstring" then
    vs=(bstring) v
  else
    print "Unsupported type:  " typ
    exit function
  end if
  '
  print typ "    " vs
  '
  end function

'======
'TESTS:
'======

long a=12345
double d=1234.5
string s="Hello!"
bstring b="GoodBye"

f a,typeof a
f d,typeof d
f s,typeof s
f b,typeof b

frees b
