msg2inc.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. {
  2. This program is part of the Free Pascal run time library.
  3. Copyright (c) 1998-2002 by Peter Vreman
  4. Convert a .msg file to an .inc file with a const array of char
  5. And for the lazy docwriters it can also generate some TeX output
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$H+}
  13. program msg2inc;
  14. {$ifdef unix}
  15. {$define EOL_ONE_CHAR}
  16. {$endif unix}
  17. {$ifdef amiga}
  18. {$define EOL_ONE_CHAR}
  19. {$endif amiga}
  20. {$ifdef morphos}
  21. {$define EOL_ONE_CHAR}
  22. {$endif}
  23. {$ifdef macos}
  24. {$define EOL_ONE_CHAR}
  25. {$endif}
  26. {$ifdef wasi}
  27. {$define EOL_ONE_CHAR}
  28. {$endif}
  29. const
  30. version='1.00';
  31. {$ifdef EOL_ONE_CHAR}
  32. eollen=1;
  33. {$else}
  34. eollen=2;
  35. {$endif}
  36. msgparts = 20;
  37. type
  38. TMode=(M_Char,M_Tex,M_Intel,M_String,M_Renumber);
  39. var
  40. InFile,
  41. OutFile,
  42. OutName : string;
  43. Mode : TMode;
  44. TexHeader : boolean;
  45. MsgTxt : pchar;
  46. EnumTxt : pchar;
  47. enumsize,
  48. msgsize : longint;
  49. msgidxmax : array[1..msgparts] of longint;
  50. msgs : array[0..msgparts,0..999] of boolean;
  51. msgcodepage: TSystemCodePage;
  52. procedure LoadMsgFile(const fn:string);
  53. var
  54. f : text;
  55. error,
  56. multiline : boolean;
  57. code : word;
  58. numpart,numidx,
  59. line,i,j,num : longint;
  60. ptxt,
  61. penum : pchar;
  62. number,
  63. s,s1 : string;
  64. procedure err(const msgstr:string);
  65. begin
  66. writeln('error in line ',line,': ',msgstr);
  67. error:=true;
  68. end;
  69. begin
  70. Writeln('Loading messagefile ',fn);
  71. msgcodepage:=CP_ACP;
  72. {Read the message file}
  73. assign(f,fn);
  74. {$push} {$I-}
  75. reset(f);
  76. {$pop}
  77. if ioresult<>0 then
  78. begin
  79. WriteLn('fatal error: '+fn+' not found');
  80. halt(1);
  81. end;
  82. { First parse the file and count bytes needed }
  83. fillchar(msgidxmax,sizeof(msgidxmax),0);
  84. fillchar(msgs,sizeof(msgs),0);
  85. error:=false;
  86. line:=0;
  87. multiline:=false;
  88. msgsize:=0;
  89. while not eof(f) do
  90. begin
  91. readln(f,s);
  92. inc(line);
  93. if multiline then
  94. begin
  95. if s=']' then
  96. multiline:=false
  97. else if (s='') or (s[1] <> '#') then
  98. inc(msgsize,length(s)+1); { +1 for linebreak }
  99. end
  100. else
  101. begin
  102. if (s<>'') and not(s[1] in ['#',';','%']) then
  103. begin
  104. i:=pos('=',s);
  105. if i>0 then
  106. begin
  107. j:=i+1;
  108. if not(s[j] in ['0'..'9']) then
  109. err('no number found')
  110. else
  111. begin
  112. while (s[j] in ['0'..'9']) do
  113. inc(j);
  114. end;
  115. if j-i-1<>5 then
  116. err('number length is not 5');
  117. number:=Copy(s,i+1,j-i-1);
  118. { update the max index }
  119. val(number,num,code);
  120. numpart:=num div 1000;
  121. if numpart=0 then
  122. err('number should be > 1000');
  123. if code<>0 then
  124. err('illegal number: '+s);
  125. numidx:=num mod 1000;
  126. { duplicate ? }
  127. if msgs[numpart,numidx] then
  128. err('duplicate number found');
  129. msgs[numpart,numidx]:=true;
  130. { check range }
  131. if numpart > msgparts then
  132. err('number is to large')
  133. else
  134. if numidx > msgidxmax[numpart] then
  135. msgidxmax[numpart]:=numidx;
  136. if s[j+1]='[' then
  137. begin
  138. inc(msgsize,j-i);
  139. multiline:=true
  140. end
  141. else
  142. inc(msgsize,length(s)-i+1);
  143. inc(enumsize,j);
  144. end
  145. else
  146. err('no = found');
  147. end
  148. else if (Length(s)>11) and (Copy(s,1,11)='# CodePage ') then
  149. begin
  150. val(Copy(s,12,Length(s)-11),msgcodepage,code);
  151. if code<>0 then
  152. err('illegal code page number: '+s);
  153. end;
  154. end;
  155. end;
  156. if multiline then
  157. err('still in multiline mode');
  158. if error then
  159. begin
  160. close(f);
  161. writeln('aborting');
  162. halt(1);
  163. end;
  164. { alloc memory }
  165. getmem(msgtxt,msgsize);
  166. { no linebreak after last entry }
  167. dec(msgsize);
  168. ptxt:=msgtxt;
  169. getmem(enumtxt,enumsize);
  170. penum:=enumtxt;
  171. { now read the buffer in mem }
  172. reset(f);
  173. while not eof(f) do
  174. begin
  175. readln(f,s);
  176. if multiline then
  177. begin
  178. if s=']' then
  179. begin
  180. multiline:=false;
  181. { overwrite last eol }
  182. dec(ptxt);
  183. ptxt^:=#0;
  184. inc(ptxt);
  185. end
  186. else if (s='') or (s[1] <> '#') then
  187. begin
  188. if length(s)>0 then
  189. begin
  190. move(s[1],ptxt^,length(s));
  191. inc(ptxt,length(s));
  192. end;
  193. ptxt^:=#10;
  194. inc(ptxt);
  195. end;
  196. end
  197. else
  198. begin
  199. if (s<>'') and not(s[1] in ['#',';','%']) then
  200. begin
  201. i:=pos('=',s);
  202. if i>0 then
  203. begin
  204. j:=i+1;
  205. while (s[j] in ['0'..'9']) do
  206. inc(j);
  207. {enum}
  208. move(s[1],penum^,i-1);
  209. inc(penum,i-1);
  210. penum^:='=';
  211. inc(penum);
  212. number:=Copy(s,i+1,j-i-1);
  213. move(number[1],penum^,length(number));
  214. inc(penum,length(number));
  215. penum^:=#0;
  216. inc(penum);
  217. { multiline start then no txt }
  218. if s[j+1]='[' then
  219. begin
  220. s1:=Copy(s,i+1,j-i);
  221. move(s1[1],ptxt^,length(s1));
  222. inc(ptxt,length(s1));
  223. multiline:=true;
  224. end
  225. else
  226. begin
  227. { txt including number }
  228. s1:=Copy(s,i+1,255);
  229. move(s1[1],ptxt^,length(s1));
  230. inc(ptxt,length(s1));
  231. ptxt^:=#0;
  232. inc(ptxt);
  233. end;
  234. end;
  235. end;
  236. end;
  237. end;
  238. close(f);
  239. end;
  240. {*****************************************************************************
  241. WriteEnumFile
  242. *****************************************************************************}
  243. procedure WriteEnumFile(const fn:string);
  244. var
  245. t : text;
  246. i : longint;
  247. p : pchar;
  248. start : boolean;
  249. begin
  250. writeln('Writing enumfile '+fn);
  251. {Open textfile}
  252. assign(t,fn);
  253. rewrite(t);
  254. writeln(t,'const');
  255. {Parse buffer in msgbuf and create indexs}
  256. p:=enumtxt;
  257. start:=true;
  258. for i:=1 to enumsize do
  259. begin
  260. if start then
  261. begin
  262. write(t,' ');
  263. start:=false;
  264. end;
  265. if p^=#0 then
  266. begin
  267. writeln(t,';');
  268. start:=true;
  269. end
  270. else
  271. begin
  272. write(t,p^);
  273. end;
  274. inc(p);
  275. end;
  276. writeln(t,'');
  277. { msgtxt size }
  278. writeln(t,' MsgTxtSize = ',msgsize,';');
  279. writeln(t,'');
  280. { max msg idx table }
  281. writeln(t,' MsgIdxMax : array[1..20] of longint=(');
  282. write(t,' ');
  283. for i:=1 to 20 do
  284. begin
  285. write(t,msgidxmax[i]+1);
  286. if i<20 then
  287. write(t,',');
  288. if i=10 then
  289. begin
  290. writeln(t,'');
  291. write(t,' ');
  292. end;
  293. end;
  294. writeln(t,'');
  295. writeln(t,' );');
  296. close(t);
  297. end;
  298. {*****************************************************************************
  299. WriteStringFile
  300. *****************************************************************************}
  301. procedure WriteStringFile(const fn,constname:string);
  302. const
  303. maxslen=240; { to overcome aligning problems }
  304. function l0(l:longint):string;
  305. var
  306. s : string[16];
  307. begin
  308. str(l,s);
  309. while (length(s)<5) do
  310. s:='0'+s;
  311. l0:=s;
  312. end;
  313. var
  314. t : text;
  315. f : file;
  316. slen,
  317. len,i : longint;
  318. p : pchar;
  319. s : string;
  320. start,
  321. quote : boolean;
  322. begin
  323. writeln('Writing stringfile ',fn);
  324. {Open textfile}
  325. assign(t,fn);
  326. rewrite(t);
  327. writeln(t,'const '+constname+'_codepage=',msgcodepage:5,';');
  328. writeln(t,'{$ifdef Delphi}');
  329. writeln(t,'const '+constname+' : array[0..000000] of string[',maxslen,']=(');
  330. writeln(t,'{$else Delphi}');
  331. writeln(t,'const '+constname+' : array[0..000000,1..',maxslen,'] of char=(');
  332. write(t,'{$endif Delphi}');
  333. {Parse buffer in msgbuf and create indexs}
  334. p:=msgtxt;
  335. slen:=0;
  336. len:=0;
  337. quote:=false;
  338. start:=true;
  339. for i:=1 to msgsize do
  340. begin
  341. if slen>=maxslen then
  342. begin
  343. if quote then
  344. begin
  345. write(t,'''');
  346. quote:=false;
  347. end;
  348. write(t,',');
  349. slen:=0;
  350. inc(len);
  351. end;
  352. if (len>70) or (start) then
  353. begin
  354. if quote then
  355. begin
  356. write(t,'''');
  357. quote:=false;
  358. end;
  359. if slen>0 then
  360. writeln(t,'+')
  361. else
  362. writeln(t);
  363. len:=0;
  364. start:=false;
  365. end;
  366. if (len=0) then
  367. write(t,' ');
  368. if (ord(p^)>=32) and (p^<>#39) then
  369. begin
  370. if not quote then
  371. begin
  372. write(t,'''');
  373. quote:=true;
  374. inc(len);
  375. end;
  376. write(t,p^);
  377. inc(len);
  378. end
  379. else
  380. begin
  381. if quote then
  382. begin
  383. write(t,'''');
  384. inc(len);
  385. quote:=false;
  386. end;
  387. write(t,'#'+chr(ord(p^) div 100+48)+chr((ord(p^) mod 100) div 10+48)+chr(ord(p^) mod 10+48));
  388. inc(len,3);
  389. end;
  390. if p^ in [#0,#10] then
  391. start:=true;
  392. inc(slen);
  393. inc(p);
  394. end;
  395. if quote then
  396. write(t,'''');
  397. writeln(t,'');
  398. writeln(t,');');
  399. close(t);
  400. {update arraysize}
  401. s:=l0((msgsize-1) div maxslen); { we start with 0 }
  402. assign(f,fn);
  403. reset(f,1);
  404. seek(f,22+34+2*eollen+2*length(constname));
  405. blockwrite(f,s[1],5);
  406. seek(f,22+90+4*eollen+3*length(constname));
  407. blockwrite(f,s[1],5);
  408. close(f);
  409. end;
  410. {*****************************************************************************
  411. WriteCharFile
  412. *****************************************************************************}
  413. procedure WriteCharFile(const fn,constname:string);
  414. function l0(l:longint):string;
  415. var
  416. s : string[16];
  417. begin
  418. str(l,s);
  419. while (length(s)<5) do
  420. s:='0'+s;
  421. l0:=s;
  422. end;
  423. function createconst(b:byte):string;
  424. begin
  425. if (b in [32..127]) and (b<>39) then
  426. createconst:=''''+chr(b)+''''
  427. else
  428. createconst:='#'+chr(b div 100+48)+chr((b mod 100) div 10+48)+chr(b mod 10+48)
  429. end;
  430. var
  431. t : text;
  432. f : file;
  433. cidx,i : longint;
  434. p : pchar;
  435. s : string;
  436. begin
  437. writeln('Writing charfile '+fn);
  438. {Open textfile}
  439. assign(t,fn);
  440. rewrite(t);
  441. writeln(t,'const ',constname,' : array[1..00000] of char=(');
  442. {Parse buffer in msgbuf and create indexs}
  443. p:=msgtxt;
  444. cidx:=0;
  445. for i:=1to msgsize do
  446. begin
  447. if cidx=15 then
  448. begin
  449. if cidx>0 then
  450. writeln(t,',')
  451. else
  452. writeln(t,'');
  453. write(t,' ');
  454. cidx:=0;
  455. end
  456. else
  457. if cidx>0 then
  458. write(t,',')
  459. else
  460. write(t,' ');
  461. write(t,createconst(ord(p^)));
  462. inc(cidx);
  463. inc(p);
  464. end;
  465. writeln(t,');');
  466. close(t);
  467. {update arraysize}
  468. s:=l0(msgsize);
  469. assign(f,fn);
  470. reset(f,1);
  471. seek(f,18+length(constname));
  472. blockwrite(f,s[1],5);
  473. close(f);
  474. end;
  475. {*****************************************************************************
  476. WriteIntelFile
  477. *****************************************************************************}
  478. procedure WriteIntelFile(const fn,constname:string);
  479. var
  480. t : text;
  481. len,i : longint;
  482. p : pchar;
  483. start,
  484. quote : boolean;
  485. begin
  486. writeln('Writing Intelfile ',fn);
  487. {Open textfile}
  488. assign(t,fn);
  489. rewrite(t);
  490. writeln(t,'procedure '+constname+';assembler;');
  491. writeln(t,'asm');
  492. {Parse buffer in msgbuf and create indexs}
  493. p:=msgtxt;
  494. len:=0;
  495. start:=true;
  496. quote:=false;
  497. for i:=1to msgsize do
  498. begin
  499. if len>70 then
  500. begin
  501. if quote then
  502. begin
  503. write(t,'''');
  504. quote:=false;
  505. end;
  506. writeln(t,'');
  507. start:=true;
  508. end;
  509. if start then
  510. begin
  511. write(t,' db ''');
  512. len:=0;
  513. quote:=true;
  514. end;
  515. if (ord(p^)>=32) and (p^<>#39) then
  516. begin
  517. if not quote then
  518. begin
  519. write(t,',''');
  520. quote:=true;
  521. inc(len);
  522. end;
  523. write(t,p^);
  524. inc(len);
  525. end
  526. else
  527. begin
  528. if quote then
  529. begin
  530. write(t,'''');
  531. inc(len);
  532. quote:=false;
  533. end;
  534. write(t,','+chr(ord(p^) div 100+48)+chr((ord(p^) mod 100) div 10+48)+chr(ord(p^) mod 10+48));
  535. inc(len,4);
  536. end;
  537. inc(p);
  538. end;
  539. if quote then
  540. write(t,'''');
  541. writeln(t,'');
  542. writeln(t,'end;');
  543. close(t);
  544. end;
  545. {*****************************************************************************
  546. RenumberFile
  547. *****************************************************************************}
  548. procedure RenumberFile(const fn,name:string);
  549. var
  550. f,t : text;
  551. i : longint;
  552. s,s1 : string;
  553. begin
  554. Writeln('Renumbering ',fn);
  555. {Read the message file}
  556. assign(f,fn);
  557. {$push} {$I-}
  558. reset(f);
  559. {$pop}
  560. if ioresult<>0 then
  561. begin
  562. WriteLn('*** message file '+fn+' not found ***');
  563. exit;
  564. end;
  565. assign(t,'msg2inc.$$$');
  566. rewrite(t);
  567. i:=0;
  568. while not eof(f) do
  569. begin
  570. readln(f,s);
  571. if (copy(s,1,length(Name))=Name) and (s[3] in ['0'..'9']) then
  572. begin
  573. inc(i);
  574. str(i,s1);
  575. while length(s1)<3 do
  576. s1:='0'+s1;
  577. writeln(t,Name+s1+Copy(s,6,255));
  578. end
  579. else
  580. writeln(t,s);
  581. end;
  582. close(t);
  583. close(f);
  584. { rename new file }
  585. erase(f);
  586. rename(t,fn);
  587. end;
  588. {*****************************************************************************
  589. WriteTexFile
  590. *****************************************************************************}
  591. Function EscapeString (Const S : String) : String;
  592. Var
  593. I : longint;
  594. hs : string;
  595. begin
  596. hs:='';
  597. i:=1;
  598. while i<=length(s) do
  599. begin
  600. case S[i] of
  601. '$' :
  602. if (s[i+1] in ['0'..'9']) then
  603. begin
  604. hs:=hs+'\textlangle arg. '+s[i+1]+'\textrangle{}';
  605. inc(i);
  606. end
  607. else
  608. hs:=hs+'\$';
  609. '&','{','}','#','_','%': // Escape these characters
  610. hs := hs + '\' + S[i];
  611. '~','^':
  612. hs := hs + '\'+S[i]+' ';
  613. '\':
  614. hs:=hs+'$\backslash$'
  615. else
  616. hs := hs + S[i];
  617. end;
  618. inc(i);
  619. end;
  620. EscapeString:=hs;
  621. end;
  622. procedure WriteTexFile(const infn,outfn:string);
  623. var
  624. t,f : text;
  625. line,
  626. i,k : longint;
  627. number,
  628. s,s1 : string;
  629. texoutput : boolean;
  630. begin
  631. Writeln('Loading messagefile ',infn);
  632. writeln('Writing TeXfile ',outfn);
  633. { Open infile }
  634. assign(f,infn);
  635. {$push} {$I-}
  636. reset(f);
  637. {$pop}
  638. if ioresult<>0 then
  639. begin
  640. WriteLn('*** message file '+infn+' not found ***');
  641. exit;
  642. end;
  643. { Open outfile }
  644. assign(t,outfn);
  645. rewrite(t);
  646. If texheader then
  647. begin
  648. writeln (t,'\documentclass{article}');
  649. writeln (t,'\usepackage{html}');
  650. writeln (t,'\usepackage{fpc}');
  651. writeln (t,'\begin{document}');
  652. end;
  653. { Parse }
  654. line:=0;
  655. TexOutput:=False;
  656. while not eof(f) do
  657. begin
  658. readln(f,s);
  659. inc(line);
  660. If Pos ('# BeginOfTeX',S)=1 then
  661. TexOutPut:=True
  662. else if pos ('# EndOfTeX',S)=1 then
  663. TexOutPut:=False;
  664. if (s<>'') and not(s[1] in ['#',';']) and TeXOutPut then
  665. begin
  666. if s[1]='%' then
  667. begin
  668. Delete(s,1,1);
  669. writeln(t,s);
  670. end
  671. else
  672. begin
  673. i:=pos('=',s);
  674. if i>0 then
  675. begin
  676. inc(i);
  677. number:='';
  678. while s[i] in ['0'..'9'] do
  679. begin
  680. number:=number+s[i];
  681. inc(i);
  682. end;
  683. { strip leading zeros }
  684. while number[1]='0' do
  685. Delete(number,1,1);
  686. inc(i);
  687. s1:='';
  688. k:=0;
  689. while (k<5) and (s[i+k]<>'_') do
  690. begin
  691. case s[i+k] of
  692. 'W' : s1:='Warning '+number+': ';
  693. 'E' : s1:='Error '+number+': ';
  694. 'F' : s1:='Fatal error '+number+': ';
  695. 'N' : s1:='Note '+number+': ';
  696. 'I' : s1:='Info '+number+': ';
  697. 'H' : s1:='Hint '+number+': ';
  698. end;
  699. inc(k);
  700. end;
  701. if s[i+k]='_' then
  702. inc(i,k+1);
  703. if number<>'' then
  704. writeln(t,'\index[msgnr]{',number,'}');
  705. writeln(t,'\index[msgtxt]{',escapestring(Copy(s,i,255)),'}');
  706. writeln(t,'\item ['+s1+escapestring(Copy(s,i,255))+'] \hfill \\');
  707. end
  708. else
  709. writeln('error in line: ',line,' skipping');
  710. end;
  711. end;
  712. end;
  713. If TexHeader then
  714. writeln (t,'\end{document}');
  715. close(t);
  716. close(f);
  717. end;
  718. {*****************************************************************************
  719. Main Program
  720. *****************************************************************************}
  721. procedure getpara;
  722. var
  723. ch : char;
  724. para : string;
  725. files,i : word;
  726. procedure helpscreen;
  727. begin
  728. writeln('usage : msg2inc [Options] <msgfile> <incfile> <constname>');
  729. writeln('<Options> can be : -T Create .doc TeX file');
  730. writeln(' -TS Create .doc TeX file (stand-alone)');
  731. writeln(' -I Intel style asm output');
  732. writeln(' -S array of string');
  733. writeln(' -C array of char');
  734. writeln(' -R renumber section <incfile>');
  735. writeln(' -V Show version');
  736. writeln(' -? or -H This HelpScreen');
  737. halt(1);
  738. end;
  739. begin
  740. Files:=0;
  741. for i:=1 to paramcount do
  742. begin
  743. para:=paramstr(i);
  744. if (para[1]='-') then
  745. begin
  746. ch:=upcase(para[2]);
  747. delete(para,1,2);
  748. case ch of
  749. 'T' : begin
  750. case upcase(para[1]) of
  751. 'S' : TexHeader:=True;
  752. end;
  753. Mode:=M_Tex;
  754. end;
  755. 'I' : Mode:=M_Intel;
  756. 'S' : Mode:=M_String;
  757. 'C' : Mode:=M_Char;
  758. 'R' : Mode:=M_Renumber;
  759. 'V' : begin
  760. Writeln('Msg2Inc ',version,' for Free Pascal (C) 1998-2002 Peter Vreman');
  761. Writeln;
  762. Halt;
  763. end;
  764. '?','H' : helpscreen;
  765. end;
  766. end
  767. else
  768. begin
  769. inc(Files);
  770. if Files>3 then
  771. HelpScreen;
  772. case Files of
  773. 1 : InFile:=Para;
  774. 2 : OutFile:=Para;
  775. 3 : OutName:=Para;
  776. end;
  777. end;
  778. end;
  779. case Mode of
  780. M_Renumber,
  781. M_Tex : if Files<2 then
  782. Helpscreen;
  783. else
  784. if Files<3 then
  785. HelpScreen;
  786. end;
  787. end;
  788. begin
  789. Mode:=M_String;
  790. OutFile:='';
  791. InFile:='';
  792. OutName:='';
  793. GetPara;
  794. case Mode of
  795. M_Renumber : begin
  796. Renumberfile(Infile,OutFile);
  797. end;
  798. M_Tex : begin
  799. WriteTexFile(InFile,Outfile);
  800. end;
  801. M_Intel : begin
  802. Loadmsgfile(InFile);
  803. WriteEnumFile(OutFile+'idx.inc');
  804. WriteIntelFile(OutFile+'txt.inc',OutName+'txt');
  805. end;
  806. M_String : begin
  807. Loadmsgfile(InFile);
  808. WriteEnumFile(OutFile+'idx.inc');
  809. WriteStringFile(OutFile+'txt.inc',OutName+'txt');
  810. end;
  811. M_Char : begin
  812. Loadmsgfile(InFile);
  813. WriteEnumFile(OutFile+'idx.inc');
  814. WriteCharFile(OutFile+'txt.inc',OutName+'txt');
  815. end;
  816. end;
  817. end.