msg2inc.pp 20 KB

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