Home > mrg > MRG_MIKE > mrg_create_npp_langdef.m

mrg_create_npp_langdef

PURPOSE ^

Creates a language definition file for NotePad++

SYNOPSIS ^

function mrg_create_npp_langdef()

DESCRIPTION ^

 Creates a language definition file for NotePad++ 

 This function scans a user-selected directory (e.g. the DHI installation
 directory) and extracts the information from the files it finds there.

 INPUT
   None. The user is prompted to select the
   userDefineLang_PFS_Template.xml file.  

 OUTPUT
   NO OUTPUT AT CONSOLE.
   Three files are generated:
       userDefineLang.xml: The language definition file
       pfs_static_list.txt: A list of 'static' PFS keywords
       pfs_variable_list.txt: The 'variable' PFS keywords

 NOTES
   The three files will be written to the same folder as the
   userDefineLang_PFS_Template.xml file, and will overwirte any files with
   the same name.  

 REQUIREMENTS
   Requires userDefineLang_PFS_Template.xml which can be found in Dans 
   MIKE PFS respository: https://github.com/dpritchard/mike_pfs_npp
   
   All that being said, you may as well just get the generated XML from 
   the above link!

 AUTHORS
   Daniel Pritchard

 LICENCE
   Code distributed as part of the MRG toolbox from the Marine Research
   Group at Queens Univeristy Belfast (QUB) School of Planning
   Architecture and Civil Engineering (SPACE). Distributed under a
   creative commons CC BY-SA licence, retaining full copyright of the
   original authors.

   http://creativecommons.org/licenses/by-sa/3.0/
   http://www.qub.ac.uk/space/
   http://www.qub.ac.uk/research-centres/eerc/

 DEVELOPMENT
   v 1.0   2013-03-??
           First version. DP
   v 1.1   2013-09-16
           Updated across the board and refactored to use mrg_oswalk() 
           and mrg_PFS_keywords()  

% Get the Template
 We assume the files with the lists are in same directory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mrg_create_npp_langdef()
0002 % Creates a language definition file for NotePad++
0003 %
0004 % This function scans a user-selected directory (e.g. the DHI installation
0005 % directory) and extracts the information from the files it finds there.
0006 %
0007 % INPUT
0008 %   None. The user is prompted to select the
0009 %   userDefineLang_PFS_Template.xml file.
0010 %
0011 % OUTPUT
0012 %   NO OUTPUT AT CONSOLE.
0013 %   Three files are generated:
0014 %       userDefineLang.xml: The language definition file
0015 %       pfs_static_list.txt: A list of 'static' PFS keywords
0016 %       pfs_variable_list.txt: The 'variable' PFS keywords
0017 %
0018 % NOTES
0019 %   The three files will be written to the same folder as the
0020 %   userDefineLang_PFS_Template.xml file, and will overwirte any files with
0021 %   the same name.
0022 %
0023 % REQUIREMENTS
0024 %   Requires userDefineLang_PFS_Template.xml which can be found in Dans
0025 %   MIKE PFS respository: https://github.com/dpritchard/mike_pfs_npp
0026 %
0027 %   All that being said, you may as well just get the generated XML from
0028 %   the above link!
0029 %
0030 % AUTHORS
0031 %   Daniel Pritchard
0032 %
0033 % LICENCE
0034 %   Code distributed as part of the MRG toolbox from the Marine Research
0035 %   Group at Queens Univeristy Belfast (QUB) School of Planning
0036 %   Architecture and Civil Engineering (SPACE). Distributed under a
0037 %   creative commons CC BY-SA licence, retaining full copyright of the
0038 %   original authors.
0039 %
0040 %   http://creativecommons.org/licenses/by-sa/3.0/
0041 %   http://www.qub.ac.uk/space/
0042 %   http://www.qub.ac.uk/research-centres/eerc/
0043 %
0044 % DEVELOPMENT
0045 %   v 1.0   2013-03-??
0046 %           First version. DP
0047 %   v 1.1   2013-09-16
0048 %           Updated across the board and refactored to use mrg_oswalk()
0049 %           and mrg_PFS_keywords()
0050 %
0051 %% Get the Template
0052 % We assume the files with the lists are in same directory
0053 old_dir = cd;
0054 [file, path] = uigetfile('userDefineLang_PFS_Template.xml', 'Get Template');
0055 cd(path)
0056 fileID = fopen(file);
0057 s = textscan(fileID,'%s','Delimiter','\n');
0058 fclose(fileID);
0059 s = s{1};
0060 
0061 %% Get the header keywords
0062 keywords = mrg_PFS_keywords;
0063 keystring = [keywords.fixed_len, keywords.variable_len];
0064 
0065 %% Combine Items
0066 keyword_string = sprintf('%s ',keystring{:});
0067 
0068 %% Populate the template
0069 s = strrep(s,'[MRG_KEYWORDS]', keyword_string);
0070 
0071 %% Write File
0072 [nrows,~]= size(s);
0073 filename = 'userDefineLang.xml';
0074 fid = fopen(filename, 'w');
0075 for row=1:nrows
0076     fprintf(fid, '%s\r\n', s{row,:});
0077 end
0078 fclose(fid);
0079 
0080 filename = 'pfs_static_list.txt';
0081 fid = fopen(filename, 'w');
0082 fprintf(fid, '%s\r\n', keywords.fixed_len{:});
0083 fclose(fid);
0084 
0085 filename = 'pfs_variable_list.txt';
0086 fid = fopen(filename, 'w');
0087 fprintf(fid, '%s\r\n', keywords.variable_len{:});
0088 fclose(fid);
0089 
0090 cd(old_dir);
0091 end

Generated on Thu 29-May-2014 21:29:53 by m2html © 2005