Function with awk script

Hi Team,
i want to create a function with below code and call it my script as
total=function_name <filename> ,filename should be parameter to be passed.
its a .ksh
pls advice!

 awk -F'"' '      
  {nf += gsub(/,/, ",") + 1   
     for(i = 2; i <= NF; i += 2)     
    nf -= gsub(/,/, ",", $i)  
       } END 
    {printf("%d\n", nf)       
  } ' file

Define a function like (c.f. man ksh ):

list is your above awk script.
Call it and retrieve its result like

RES=$(varname filename)

The filename parameter is supplied as the function's positional p. $1 , so $1 should designate the awk script's input stream.