def convert_function(token, num_args)
    exit "Unknown function #{token}() in formula\n" if @functions[token][0].nil?

    args = @functions[token][1]

    # Fixed number of args eg. TIME($i,$j,$k).
    if (args >= 0)
      # Check that the number of args is valid.
      if (args != num_args)
        raise "Incorrect number of arguments for #{token}() in formula\n"
      else
        return [@ptg['ptgFuncV'], @functions[token][0]].pack("Cv")
      end
    end

    # Variable number of args eg. SUM(i,j,k, ..).
    if (args == -1)
      return [@ptg['ptgFuncVarV'], num_args, @functions[token][0]].pack("CCv")
    end
  end
def convert_function(token, num_args)
    exit "Unknown function #{token}() in formula\n" if @functions[token][0].nil?

    args = @functions[token][1]

    # Fixed number of args eg. TIME($i,$j,$k).
    if (args >= 0)
      # Check that the number of args is valid.
      if (args != num_args)
        raise "Incorrect number of arguments for #{token}() in formula\n"
      else
        return [@ptg['ptgFuncV'], @functions[token][0]].pack("Cv")
      end
    end

    # Variable number of args eg. SUM(i,j,k, ..).
    if (args == -1)
      return [@ptg['ptgFuncVarV'], num_args, @functions[token][0]].pack("CCv")
    end
  end
Convert a function to a ptgFunc or ptgFuncVarV depending on the number of
 args that it takes.