Home > utils > add_tags.m

add_tags

PURPOSE ^

SYNOPSIS ^

function add_tags(filename,tag_prepend,tag_append)

DESCRIPTION ^

 opens a file and adds tag_prepend and tag_append before and after the current
 file contents.
 
 This is useful for inserting simple html, for example, <table><tr></td> and
 </td></tr></table> tags to the beginning and end of a word or sentence in a
 text file. If you have a series of files to which you need
 to add these tags, you can call this function from a short script that cycles through all of the file names.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function add_tags(filename,tag_prepend,tag_append)
0002 %
0003 % opens a file and adds tag_prepend and tag_append before and after the current
0004 % file contents.
0005 %
0006 % This is useful for inserting simple html, for example, <table><tr></td> and
0007 % </td></tr></table> tags to the beginning and end of a word or sentence in a
0008 % text file. If you have a series of files to which you need
0009 % to add these tags, you can call this function from a short script that cycles through all of the file names.
0010 %
0011 
0012 fid = fopen(filename,'r');
0013 contents = char(fread(fid))';
0014 
0015 new_contents = [tag_prepend contents tag_append];
0016 fclose(fid);
0017 
0018 fid = fopen(filename,'w');
0019 
0020 fwrite(fid,new_contents,'uchar');
0021 fclose(fid);

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003