msg2inc.pp 20 KB

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