You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: saveNEV.m
    path of file: ./repos/fieldtrip/external/npmk/NEV Utilities
    
    the code of the file until where you have to start completion: function saveNEV(NEV, varargin)

%% 
% Save an .NEV file from an NEV structure (gained by using openNEV)
% Works with file spec 2.3
% 
% Use saveNEV(NEV, filename, noreport)

% All input arguments are optional. Input arguments can be in any order.
%
%   NEV:        Name of the NEV structure to be saved.
%               DEFAULT: The workspace NEV structure in the workspace will
%               be saved.
%
%   filename:   Name of the new NEV file name.
%               DEFAULT: -out.nev will be added to the end of the current
%               file name.
%
%   'noreport': Will not display status reports or warnings.
%               DEFAULT: will display status reports and warnings.
%
%
%   OUTPUT:     None
%
%   Example 1: 
%   saveNEV
%
%   In the example above, a new file containing the NEV structure in the
%   workspace will be saved. The file name will have -out.NEV added to its
%   name. Statuses of the progress of saveNEV and also warnings about the
%   risks of saving will be displayed.
%
%   Example 2:
%   openNSx(NEV, 'myNewNEVFile.nev', 'noreport');
%
%   In the example above, a new file containing the NEV structure in the
%   workspace will be saved. The file name will be myNewNEVFile.nev. 
%   Statuses of the progress of saveNEV and also warnings about the
%   risks of saving will be not be displayed.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Nick Halper
%   support@blackrockmicro.com
%   Blackrock Microsystems
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Version History
%
% 1.0.0.0: Nick Halper
%   - Initial release.
%
% 1.1.0.0: Kian Torab
%   - Added the ability to suppress the fiel saving warning with
%     'noreport' input parameter.
%   - Re-structured help to better match the suite's style. Added examples.
%   - Added the 'noreport' key to supress statuses and warnings.
%   - Improved error checking for input arguments.
%
% 1.2.0.0: Nick Halper - 19/8/29
%   - Allows saveNEV to dynamically determine header offset and total
%   number of extended headers instead of relying on info in MetaTags/Raw
%   Data of NEV structure.
%   - Fixed a bug where choosing to overwrite would crash the script
%   - Fixed an issue where bank letters were not being written correctly, writing
%   blank values
%   - Modified the script to work with 256 channel files

    
function saveNEV(NEV, varargin)

%% 
% Save an .NEV file from an NEV structure (gained by using openNEV)
% Works with file spec 2.3
% 
% Use saveNEV(NEV, filename, noreport)

% All input arguments are optional. Input arguments can be in any order.
%
%   NEV:        Name of the NEV structure to be saved.
%               DEFAULT: The workspace NEV structure in the workspace will
%               be saved.
%
%   filename:   Name of the new NEV file name.
%               DEFAULT: -out.nev will be added to the end of the current
%               file name.
%
%   'noreport': Will not display status reports or warnings.
%               DEFAULT: will display status reports and warnings.
%
%
%   OUTPUT:     None
%
%   Example 1: 
%   saveNEV
%
%   In the example above, a new file containing the NEV structure in the
%   workspace will be saved. The file name will have -out.NEV added to its
%   name. Statuses of the progress of saveNEV and also warnings about the
%   risks of saving will be displayed.
%
%   Example 2:
%   openNSx(NEV, 'myNewNEVFile.nev', 'noreport');
%
%   In the example above, a new file containing the NEV structure in the
%   workspace will be saved. The file name will be myNewNEVFile.nev. 
%   Statuses of the progress of saveNEV and also warnings about the
%   risks of saving will be not be displayed.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Nick Halper
%   support@blackrockmicro.com
%   Blackrock Microsystems
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Version History
%
% 1.0.0.0: Nick Halper
%   - Initial release.
%
% 1.1.0.0: Kian Torab
%   - Added the ability to suppress the fiel saving warning with
%     'noreport' input parameter.
%   - Re-structured help to better match the suite's style. Added examples.
%   - Added the 'noreport' key to supress statuses and warnings.
%   - Improved error checking for input arguments.
%
% 1.2.0.0: Nick Halper - 19/8/29
%   - Allows saveNEV to dynamically determine header offset and total
%   number of extended headers instead of relying on info in MetaTags/Raw
%   Data of NEV structure.
%   - Fixed a bug where choosing to overwrite would crash the script
%   - Fixed an issue where bank letters were not being written correctly, writing
%   blank values
%   - Modified the script to work with 256 channel files
%
% 1.3.0.0: Stephen hou - 19/8/30
%   - Implemented saving of files that contain NeuroMotive/tracking data
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Verify FilePath and establish overwrite paramaters
if not(NEV.MetaTags.FileSpec == '2.3')
    disp(strcat('This function only functions on file spec 2.3,;this is your file spec:',NEV.MetaTags.FileSpec));
    return
end

if nargin > 1
    for idx = 1:nargin-1
        if strcmpi(varargin{idx}, 'noreport')
            reportFlag = 0;
        elseif length(varargin{idx})>3 && ...
                (strcmpi(varargin{idx}(3),'\') || ...
                 strcmpi(varargin{idx}(1),'/') || ...
                 strcmpi(varargin{idx}(2),'/') || ...
                 strcmpi(varargin{idx}(1:2), '\\')) 
            FilePath = varargin{1};
        end
    end
end

% Validating input arguments
if ~exist('FilePath',   'var'); FilePath = [fullfile(NEV.MetaTags.FilePath,NEV.MetaTags.Filename) '-out.nev']; end
if ~exist('reportFlag', 'var'); reportFlag = 1; end;

% Warning user about the consequences of the modified NEV file
if reportFlag
    Accept = input('This script will save a new file with the .NEV extensions, but you should retain the previous file. Do you acknowledge the risk inherent in saving modified versions of data files? (Y/N)','s');
    if ~strcmpi(Accept,'y')
        disp('Ending Script...');
        return
    end