Changeset 591 for GPL/trunk/tools
- Timestamp:
- Mar 9, 2017, 12:59:01 AM (9 years ago)
- File:
-
- 1 edited
-
GPL/trunk/tools/AddToFile.cmd (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/tools/AddToFile.cmd
r587 r591 1 /* Add specified line to file */ 2 /* Adds the specified line to the end of the specified file. 3 * Usage: 4 * AddToFile.cmd FileName,PrefixString,Function[,Parameters...] 1 /** AddToFile.cmd 2 * Adds the specified line to the end of the specified file. 3 * Written by and Copyright (c) 2010-2016 David Azarewicz http://88watts.net 5 4 * 6 * Examples: 7 * AddToFile.cmd FileName,#define DDATE,DATEL 8 * Adds today's date to Filename: #define DDATE 20130312L 5 * @#D Azarewicz:1.01#@##1## 16 Sep 2016 DAZAR1 ::::::@@AddToFile.cmd (c) David Azarewicz 2016 6 * V1.01 16-Sep-2016 First official release 9 7 * 10 * AddToFile.cmd FileName,#define BLDLEVEL,BLDLEVEL2,D Azarewicz,1.2.3,Description,Fixpack 11 * Adds a formatted BLDLEVEL string to Filename using double quotes: #define BLDLEVEL "<bldlevel string>" 12 * 13 * AddToFile.cmd FileName,option description,BLDLEVEL,D Azarewicz,1.2.3,Description,Fixpack 14 * Adds a formatted BLDLEVEL string to Filename using single quotes: option description '<bldlevel string>' 15 * 16 * AddToFile.cmd FileName,InFileName,FILE 17 */ 18 19 parse arg OutFile','String','What','ProjVendor','BuildVersion','ProductName','FixPack; 8 * The following line is for the help sample code for the VAR function: 9 EXAMPLEVAR=Example String 10 */ 11 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 12 call SysLoadFuncs 13 parse arg OutFile','String','Function','Parm1','Parm2','Parm3','Parm4; 14 15 if (OutFile='') then do 16 Say 'Usage:'; 17 Say ' AddToFile.cmd FileName,String,Function[,Parameters...]'; 18 Say 'Functions:'; 19 Say ' DATEL - Adds the date as a long number.'; 20 Say ' BLDLEVEL - Adds a formatted BLDLEVEL string.'; 21 Say ' DATEYEAR - Adds the current year.'; 22 Say ' DATEMONTH - Adds the current month.'; 23 Say ' DATEDAY - Adds the current day.'; 24 Say ' VERSIONMAJOR - Adds the major portion of the provided version number.'; 25 Say ' VERSIONMINOR - Adds the minor portion of the provided version number.'; 26 Say ' VERSIONREVISION - Adds the revision portion of the provided version number.'; 27 Say ' VAR - Adds the value of the specified variable from a specified file.'; 28 Say ' FILE - Adds the contents of a file.'; 29 Say 'Examples:'; 30 MyFile='AddToFile.tmp'; 31 rc=SysFileDelete(MyFile); 32 MyCmd=MyFile||',#define DDATE,DATEL'; 33 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 34 call 'AddToFile.cmd' MyCmd; 35 MyCmd=MyFile||',option description,BLDLEVEL,Vendor,1.2.3,Description,Fixpack'; 36 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 37 call 'AddToFile.cmd' MyCmd; 38 MyCmd=MyFile||',char *bl = "%A";,BLDLEVEL,Vendor,1.2.3,Description,Fixpack'; 39 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 40 call 'AddToFile.cmd' MyCmd; 41 MyCmd=MyFile||',#define DYEAR,DATEYEAR'; 42 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 43 call 'AddToFile.cmd' MyCmd; 44 MyCmd=MyFile||',#define DMONTH,DATEMONTH'; 45 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 46 call 'AddToFile.cmd' MyCmd; 47 MyCmd=MyFile||',#define DDAY,DATEDAY'; 48 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 49 call 'AddToFile.cmd' MyCmd; 50 MyCmd=MyFile||',#define DVMAJ,VERSIONMAJOR,1.2.3'; 51 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 52 call 'AddToFile.cmd' MyCmd; 53 MyCmd=MyFile||',#define DVMIN,VERSIONMINOR,1.2.3'; 54 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 55 call 'AddToFile.cmd' MyCmd; 56 MyCmd=MyFile||',#define DVREV,VERSIONREVISION,1.2.3'; 57 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 58 call 'AddToFile.cmd' MyCmd; 59 MyCmd=MyFile||',#define XYZ "%A",VAR,EXAMPLEVAR=,AddToFile.cmd'; 60 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 61 call 'AddToFile.cmd' MyCmd; 62 MyCmd=MyFile||',InFileName,FILE'; 63 rc=LineOut(MyFile, '--- AddToFile.cmd '||MyCmd); 64 call 'AddToFile.cmd' MyCmd; 65 do while LINES(MyFile) <> 0; 66 Say LINEIN(MyFile); 67 end; 68 rc=stream(MyFile,'c','close'); 69 rc=SysFileDelete(MyFile); 70 exit; 71 end 20 72 21 73 select 22 when (What='DATEL') then do 23 rc=lineout(OutFile, String||' '||DATE('S')||'L'); 24 rc=lineout(OutFile); 25 end 26 27 when (LEFT(What,8)='BLDLEVEL') then do 28 Type=SUBSTR(What,9,1); 74 when (Function='DATEL') then do 75 NewStr=DATE('S')||'L' 76 RepLoc=Pos('%A', String); 77 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 78 else OutStr=String||' '||NewStr; 79 rc=lineout(OutFile, OutStr); 80 rc=lineout(OutFile); 81 end 82 83 when (LEFT(Function,8)='BLDLEVEL') then do 84 Type=SUBSTR(Function,9,1); 29 85 30 86 /* get hostname for build system */ … … 35 91 36 92 /* get fixpack from SVN version */ 37 if (FixPack='SVN') then FixPack='SVN'||SvnVersion(); 38 39 parse var BuildVersion major'.'minor'.'ProjVersion; 40 93 if (Parm4='SVN') then Parm4='SVN'||SvnVersion(); 94 95 parse var Parm2 major'.'minor'.'ProjVersion; 96 97 RepLoc=Pos('%Y', Parm3); 98 if (RepLoc>0) then do 99 Parm3=Substr(Parm3,1,RepLoc-1)||FORMAT(SUBSTR(DATE('S'), 1, 4))||Substr(Parm3,RepLoc+2); 100 end 101 102 NewStr='@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||'::::'||ProjVersion||'::'||Parm4||'@@'||Parm3; 41 103 if (Type='2') then do 42 rc=lineout(OutFile, String||' "@#'||ProjVendor||':'||BuildVersion||'#@##1## '||ProjString||'::::'||ProjVersion||'::'||FixPack||'@@'||ProductName||'"'); 104 /*OutStr=String||' "@#'||Parm1||':'||Parm2||'#@##1## '||ProjString||'::::'||ProjVersion||'::'||Parm4||'@@'||Parm3||'"';*/ 105 OutStr=String||' "'||NewStr||'"'; 43 106 end 44 107 else do 45 rc=lineout(OutFile, String||" '@#"||ProjVendor||":"||BuildVersion||"#@##1## "||ProjString||"::::"||ProjVersion||"::"||FixPack||"@@"||ProductName||"'"); 108 RepLoc=Pos('%A', String); 109 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 110 else OutStr=String||" '"||NewStr||"'"; 46 111 end 47 rc=lineout(OutFile); 48 end 49 50 when (What='DATEYEAR') then do 51 rc=lineout(OutFile, String||' '||FORMAT(SUBSTR(DATE('S'), 1, 4))); 52 rc=lineout(OutFile); 53 end 54 55 when (What='DATEMONTH') then do 56 rc=lineout(OutFile, String||' '||FORMAT(SUBSTR(DATE('S'), 5, 2))); 57 rc=lineout(OutFile); 58 end 59 60 when (What='DATEDAY') then do 61 rc=lineout(OutFile, String||' '||FORMAT(SUBSTR(DATE('S'), 7, 2))); 62 rc=lineout(OutFile); 63 end 64 65 when (What="VERSIONMAJOR") then do 66 parse var ProjVendor Major'.'Minor'.'Revision; 67 rc=lineout(OutFile, String||' '||FORMAT(Major)); 68 rc=lineout(OutFile); 69 end 70 71 when (What="VERSIONMINOR") then do 72 parse var ProjVendor Major'.'Minor'.'Revision; 73 rc=lineout(OutFile, String||' '||FORMAT(Minor)); 74 rc=lineout(OutFile); 75 end 76 77 when (What="VERSIONREVISION") then do 78 parse var ProjVendor Major'.'Minor'.'Revision; 79 rc=lineout(OutFile, String||' '||FORMAT(Revision)); 80 rc=lineout(OutFile); 81 end 82 83 when (What="FILE") then do 112 rc=lineout(OutFile, OutStr); 113 rc=lineout(OutFile); 114 end 115 116 when (Function='DATEYEAR') then do 117 NewStr=FORMAT(SUBSTR(DATE('S'), 1, 4)); 118 RepLoc=Pos('%A', String); 119 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 120 else OutStr=String||' '||NewStr; 121 rc=lineout(OutFile, OutStr); 122 rc=lineout(OutFile); 123 end 124 125 when (Function='DATEMONTH') then do 126 NewStr=FORMAT(SUBSTR(DATE('S'), 5, 2)); 127 RepLoc=Pos('%A', String); 128 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 129 else OutStr=String||' '||NewStr; 130 rc=lineout(OutFile, OutStr); 131 rc=lineout(OutFile); 132 end 133 134 when (Function='DATEDAY') then do 135 NewStr=FORMAT(SUBSTR(DATE('S'), 7, 2)); 136 RepLoc=Pos('%A', String); 137 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 138 else OutStr=String||' '||NewStr; 139 rc=lineout(OutFile, OutStr); 140 rc=lineout(OutFile); 141 end 142 143 when (Function="VERSIONMAJOR") then do 144 parse var Parm1 Major'.'Minor'.'Revision; 145 NewStr=FORMAT(Major); 146 RepLoc=Pos('%A', String); 147 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 148 else OutStr=String||' '||NewStr; 149 rc=lineout(OutFile, OutStr); 150 rc=lineout(OutFile); 151 end 152 153 when (Function="VERSIONMINOR") then do 154 parse var Parm1 Major'.'Minor'.'Revision; 155 NewStr=FORMAT(Minor); 156 RepLoc=Pos('%A', String); 157 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 158 else OutStr=String||' '||NewStr; 159 rc=lineout(OutFile, OutStr); 160 rc=lineout(OutFile); 161 end 162 163 when (Function="VERSIONREVISION") then do 164 parse var Parm1 Major'.'Minor'.'Revision; 165 NewStr=FORMAT(Revision); 166 RepLoc=Pos('%A', String); 167 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 168 else OutStr=String||' '||NewStr; 169 rc=lineout(OutFile, OutStr); 170 rc=lineout(OutFile); 171 end 172 173 when (Function="FILE") then do 84 174 do while LINES(String) <> 0; 85 175 rc=LINEOUT(OutFile, LINEIN(String)); … … 89 179 end 90 180 91 when (What="VAR") then do 92 Line2 = ''; 93 Len=LENGTH(ProjVendor); 94 do while LINES(BuildVersion) <> 0; 95 Line1=LINEIN(BuildVersion); 96 if (LEFT(Line1, Len) = ProjVendor) then do 97 Line2=SUBSTR(Line1, Len+1); 181 when (Function="VAR") then do 182 Type=SUBSTR(Function,4,1); 183 NewStr = ''; 184 Len=LENGTH(Parm1); 185 do while LINES(Parm2) <> 0; 186 Line1=LINEIN(Parm2); 187 if (LEFT(Line1, Len) = Parm1) then do 188 NewStr=SUBSTR(Line1, Len+1); 98 189 LEAVE; 99 190 end 100 191 end; 101 rc=stream(BuildVersion,'c','close'); 102 rc=LINEOUT(OutFile, String||' '||Line2); 192 rc=stream(Parm2,'c','close'); 193 194 RepLoc=Pos('%A', String); 195 if (RepLoc>0) then OutStr=Substr(String,1,RepLoc-1)||NewStr||Substr(String,RepLoc+2); 196 else OutStr=String||' '||NewStr; 197 rc=LINEOUT(OutFile, OutStr); 103 198 rc=lineout(OutFile); 104 199 end 105 200 106 201 otherwise do 107 say "AddToFile: Unrecognized command: "|| What;202 say "AddToFile: Unrecognized command: "||Function; 108 203 exit 1; 109 204 end
Note:
See TracChangeset
for help on using the changeset viewer.
