source: trunk/slide-show/source/addnls.CMD@ 2

Last change on this file since 2 was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 2.6 KB
Line 
1/* */
2call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
3call SysLoadFuncs
4
5IF ARG()=1 THEN DO
6 datafile=ARG(1)
7END
8ELSE DO
9 datafile=nls001.txt
10END
11 hintini='lang.ini'
12
13lang=TRANSLATE(LEFT(RIGHT(datafile, 6), 2))
14index=0
15
16SAY 'Datafile with NLS strings: '||datafile
17SAY ''
18SAY ARG()
19/* Read the datafile */
20 i = 0
21 do while lines(datafile) <> 0
22 i=i+1
23 data.i = linein(datafile)
24 END
25 data.0=i
26
27 call stream datafile, 'C', 'CLOSE'
28
29
30 /* Correct tip numbers */
31 currentline=1
32 do while currentline <= data.0
33 section = Strip(Translate(word(data.currentline,1)))
34 select
35 when (Left(section,1) = '#') | section = '' then
36 do
37 /* Jump comments and empty lines */
38 end;
39 otherwise
40 IF POS('[',section)=1 THEN DO
41 index=index+1
42 data.currentline='['index']'
43 END
44 end
45 currentline=currentline+1
46 end
47
48
49 currentline=1
50 do while currentline <= data.0
51 section = Strip(Translate(word(data.currentline,1)))
52 select
53 when (Left(section,1) = '#') | section = '' then
54 do
55 /* Jump comments and empty lines */
56 end;
57 otherwise
58 call parseapp currentline
59 nop
60 end
61 currentline=currentline+1
62 end
63
64/* Set general info like number of tips */
65RETURN
66
67
68parseapp:
69 app=STRIP(TRANSLATE(data.currentline,' ','[]'))
70 currentline=currentline+1
71 do a=currentline to data.0
72 section = Strip(data.a)
73 select
74 when (Left(section,1) = '#') | section = '' then
75 do
76 /* Jump comments and empty lines */
77 end;
78 WHEN (Left(section,1) = '[') THEN DO
79 /* Next section reached */
80 currentline=currentline-1
81 return
82 END
83 otherwise
84 section=replaceCR(section)
85 section=replaceTab(section)
86 say app||": "||section
87 SAY ""
88 rc=SysIni(hintini, lang, word(section,1), STRIP(subword(section, 2)))
89 /* Parse source and target */
90 end
91 currentline=currentline+1
92 end
93return
94
95
96replaceCR:
97
98 string=STRIP(ARG(1))
99
100 thePos=WORDPOS("0ax",string)
101 if thePos\=0 THEN DO
102 string=SUBWORD(string,1,thePos-1)||'0a'x||replaceCR(SUBWORD(string,thePos+1))
103 END
104
105return string
106
107replaceTab:
108
109 string=STRIP(ARG(1))
110 thePos=WORDPOS("0tx",string)
111 if thePos\=0 THEN DO
112 string=SUBWORD(string,1,thePos-1)||' '||replaceTab(SUBWORD(string,thePos+1))
113 END
114
115 thePos=WORDPOS("0t2x",string)
116 if thePos\=0 THEN DO
117 string=SUBWORD(string,1,thePos-1)||'0a'x||' '||replaceTab(SUBWORD(string,thePos+1))
118 END
119
120return string
121
122
Note: See TracBrowser for help on using the repository browser.