source: trunk/guitools/shared/nlv.vrs@ 913

Last change on this file since 913 was 894, checked in by Alex Taylor, 10 years ago

Various UI tweaks, see changes for details. Enabled detection of Blue Lion system. Added some missing icons.

File size: 6.0 KB
Line 
1/*:VRX NLVSetup
2 */
3NLVSetup: PROCEDURE EXPOSE settings. options.
4 /* This subroutine is (c) by Alex Taylor, portions (c) Herwig Bauernfeind
5 * Sets all UI text from the message file. Any string that can't be loaded
6 * will default to the built-in English.
7 */
8
9 IF options.!debug == 1 THEN SAY time()' NLVSetup() started'
10 IF options.!debug == 1 THEN SAY ' NLVSetup() is (c) Alex Taylor, portions (c) Herwig Bauernfeind'
11
12 execPath = VRGet("Application", "Program")
13 if execPath = "" then parse source . . execPath
14 execDir = translate(VRParseFileName( execPath, "DP"))
15 parse var execDir srchroot '\BIN'
16
17 say ' NLV execDir = "'execDir'"'
18 say ' NLV srchroot = "'srchRoot'"'
19
20 filestem = VRParseFileName( execPath, "N")
21 if translate(filestem) = "EVFSGUI" then filestem = "evfsi_"
22 else filestem = SUBSTR( filestem, 1, 6, '_' )
23 say ' NLV filestem = "'filestem'"'
24
25 /* First, figure out what language/message file to use */
26 Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT'))
27 SELECT
28 WHEN Syslang == 'ZH_TW' THEN nlv = 'TW'
29 WHEN Syslang == 'ZH_CN' THEN nlv = 'CX'
30 OTHERWISE PARSE VAR Syslang nlv '_' .
31 END
32
33 /* Find the messagefile and helpfile */
34 settings.!messages = NLVsearch(nlv,'LANG','MSG','DPATH')
35 settings.!helpfile = NLVsearch(nlv,'HELP','HLP','HELP')
36
37 IF options.!debug == 1 THEN SAY ' NLV MessageFile = "'settings.!messages'"'
38 IF options.!debug == 1 THEN SAY ' NLV HelpFile = "'settings.!helpfile'"'
39
40 IF options.!debug == 1 THEN SAY time()' NLVSetup() done'
41RETURN
42
43/*:VRX NLVSearch
44*/
45NLVSearch: procedure expose filestem execdir srchroot
46 nlv = arg(1)
47 SubDir = arg(2)
48 Suffix = arg(3)
49 PathVar = arg(4)
50 say time()" NLVSearch() started"
51 NLVSrchDone = 0
52 NLVFile = ""
53 do until NLVSrchDone = 1
54 say ' NLV 'Suffix' file = "'filestem||nlv'.'Suffix'"'
55 select
56 when VRFileExists(srchRoot'\'SubDir'\'filestem||nlv'.'Suffix) then do
57 say " NLV "Suffix" file found directly!"
58 NLVFile = strip(srchRoot'\'SubDir'\'filestem||nlv'.'Suffix,'L','\')
59 NLVSrchDone = 1
60 end
61 when SysSearchPath(PathVar, filestem||nlv'.'Suffix) \= '' then do
62 execDir = VRParseFileName(SysSearchPath(PathVar, filestem||nlv'.'Suffix),"DP")
63 say " NLV "Suffix" file found via "PathVar
64 NLVFile = strip(execdir'\'filestem||nlv'.'Suffix,'L','\')
65 NLVSrchDone = 1
66 end
67 otherwise do
68 say " Searching subdirectories"
69 ok = SysFileTree(srchRoot'\'filestem||nlv'.'Suffix,nlvmsg.,'FOS')
70 if nlvmsg.0 = 1 then do
71 say " Found NLV "Suffix" file in subdirectory"
72 NLVFile = VRParseFilename(nlvmsg.1,"DPN")'.'Suffix
73 say " Adding NLV "Suffix" path to "PathVar
74 OldPathVar = value(PathVar,,"OS2ENVIRONMENT")
75 ok = value(PathVar,VRParseFilename(nlvmsg.1,"DP")';'OldPathVar,"OS2ENVIRONMENT")
76 NLVSrchDone = 1
77 end
78 else say " NLV "Suffix" file not found in subdirectories!"
79 end
80 end
81 if NLVSrchDone = 0 then do /* Fallback to English */
82 if nlv = "EN" then do
83 NLVSrchDone = 1 /* We give up and leave */
84 id = VRMessage( "", "Could not find a valid language file!", "NLV Setup Error", "E", )
85 /* We will leave without a valid NLV file here! */
86 end
87 else do
88 say " NLV "Suffix" File not found, falling back to EN."
89 nlv = "EN"
90 /* Now we repeat the whole procedure to find the EN file */
91 end
92 end
93 end
94 say time()' NLVSearch() done, returning "'NLVFile'"'
95return NLVFile
96
97/*:VRX NLVGetMessage
98*/
99NLVGetMessage: PROCEDURE EXPOSE settings. options. fs.
100
101 msgfile = settings.!messages
102 msgnum = ARG( 1 )
103
104 IF msgfile == '' THEN RETURN ''
105 IF msgnum == '' THEN RETURN ''
106
107 SELECT
108 WHEN ARG() == 2 THEN
109 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2) )
110 WHEN ARG() == 3 THEN
111 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3) )
112 WHEN ARG() == 4 THEN
113 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4) )
114 WHEN ARG() == 5 THEN
115 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5) )
116 WHEN ARG() == 6 THEN
117 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6) )
118 WHEN ARG() == 7 THEN
119 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7) )
120 WHEN ARG() == 8 THEN
121 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8) )
122 WHEN ARG() == 9 THEN
123 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9) )
124 WHEN ARG() == 10 THEN
125 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10) )
126 OTHERWISE
127 msgtxt = SysGetMessage( msgnum, msgfile )
128 END
129
130 PARSE VAR msgtxt message '0D'x .
131
132 IF translate(SUBSTR( message, 1, 4 )) == 'SYS0' THEN message = '[Missing message 'msgnum'!]'
133
134RETURN message
135
136/*:VRX NLVSetText
137*/
138/*
139 * Sets the specified property of the specified control to the specified
140 * message text.
141 */
142NLVSetText: PROCEDURE EXPOSE settings. options. fs.
143 PARSE ARG control, property, message, substitution
144
145 success = 1
146 IF substitution == '' THEN
147 text = NLVGetMessage( message )
148 ELSE
149 text = NLVGetMessage( message, substitution )
150
151 IF text == '' THEN success = 0
152 ELSE CALL VRSet control, property, text
153
154RETURN success
Note: See TracBrowser for help on using the repository browser.