source: branches/guitools-2.0/shared/nlv.vrs@ 361

Last change on this file since 361 was 361, checked in by Herwig Bauernfeind, 16 years ago

GUI-Tools: EVFSGUI basics for printer support

File size: 5.7 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 say ' NLV filestem = "'filestem'"'
23
24 /* First, figure out what language/message file to use */
25 Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT'))
26 SELECT
27 WHEN Syslang == 'ZH_TW' THEN nlv = 'TW'
28 WHEN Syslang == 'ZH_CN' THEN nlv = 'CX'
29 OTHERWISE PARSE VAR Syslang nlv '_' .
30 END
31
32 /* Find the messagefile and helpfile */
33 settings.!messages = NLVsearch(nlv,'LANG','MSG','DPATH')
34 settings.!helpfile = NLVsearch(nlv,'HELP','HLP','HELP')
35
36 IF options.!debug == 1 THEN SAY ' NLV MessageFile = "'settings.!messages'"'
37 IF options.!debug == 1 THEN SAY ' NLV HelpFile = "'settings.!helpfile'"'
38
39 IF options.!debug == 1 THEN SAY time()' NLVSetup() done'
40RETURN
41
42/*:VRX NLVSearch
43*/
44NLVSearch: procedure expose filestem execdir srchroot
45 nlv = arg(1)
46 SubDir = arg(2)
47 Suffix = arg(3)
48 PathVar = arg(4)
49 say time()" NLVSearch() started"
50 NLVSrchDone = 0
51 NLVFile = ""
52 do until NLVSrchDone = 1
53 say ' NLV 'Suffix' file = "'filestem||nlv'.'Suffix'"'
54 select
55 when VRFileExists(srchRoot'\'SubDir'\'filestem||nlv'.'Suffix) then do
56 say " NLV "Suffix" file found directly!"
57 NLVFile = strip(srchRoot'\'SubDir'\'filestem||nlv'.'Suffix,'L','\')
58 NLVSrchDone = 1
59 end
60 when SysSearchPath(PathVar, filestem||nlv'.'Suffix) \= '' then do
61 execDir = VRParseFileName(SysSearchPath(PathVar, filestem||nlv'.'Suffix),"DP")
62 say " NLV "Suffix" file found via "PathVar
63 NLVFile = strip(execdir'\'filestem||nlv'.'Suffix,'L','\')
64 NLVSrchDone = 1
65 end
66 otherwise do
67 say " Searching subdirectories"
68 ok = SysFileTree(srchRoot'\'filestem||nlv'.'Suffix,nlvmsg.,'FOS')
69 if nlvmsg.0 = 1 then do
70 say " Found NLV "Suffix" file in subdirectory"
71 settings.!messages = VRParseFilename(nlvmsg.1,"DPN")'.msg'
72 say " Adding NLV "Suffix" path to "PathVar
73 OldPathVar = value(PathVar,,"OS2ENVIRONMENT")
74 ok = value(PathVar,VRParseFilename(nlvmsg.1,"DP")';'OldPathVar,"OS2ENVIRONMENT")
75 NLVSrchDone = 1
76 end
77 else say " NLV "Suffix" file not found in subdirectories!"
78 end
79 end
80 if NLVSrchDone = 0 then do /* Fallback to English */
81 if nlv = "EN" then NLVSrchDone = 1 /* We give up and leave */
82 else do
83 say " NLV "Suffix" File not found, falling back to EN."
84 nlv = "EN"
85 end
86 end
87 end
88 say time()' NLVSearch() done, returning "'NLVFile'"'
89return NLVFile
90
91/*:VRX NLVGetMessage
92*/
93NLVGetMessage: PROCEDURE EXPOSE settings. options. fs.
94
95 msgfile = settings.!messages
96 msgnum = ARG( 1 )
97
98 IF msgnum == '' THEN RETURN ''
99
100 SELECT
101 WHEN ARG() == 2 THEN
102 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2) )
103 WHEN ARG() == 3 THEN
104 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3) )
105 WHEN ARG() == 4 THEN
106 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4) )
107 WHEN ARG() == 5 THEN
108 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5) )
109 WHEN ARG() == 6 THEN
110 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6) )
111 WHEN ARG() == 7 THEN
112 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7) )
113 WHEN ARG() == 8 THEN
114 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8) )
115 WHEN ARG() == 9 THEN
116 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9) )
117 WHEN ARG() == 10 THEN
118 msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10) )
119 OTHERWISE
120 msgtxt = SysGetMessage( msgnum, msgfile )
121 END
122
123 PARSE VAR msgtxt message '0D'x .
124
125 IF translate(SUBSTR( message, 1, 4 )) == 'SYS0' THEN message = ''
126
127RETURN message
128
129/*:VRX NLVSetText
130*/
131/*
132 * Sets the specified property of the specified control to the specified
133 * message text.
134 */
135NLVSetText: PROCEDURE EXPOSE settings. options. fs.
136 PARSE ARG control, property, message, substitution
137
138 success = 1
139 IF substitution == '' THEN
140 text = NLVGetMessage( message )
141 ELSE
142 text = NLVGetMessage( message, substitution )
143
144 IF text == '' THEN success = 0
145 ELSE CALL VRSet control, property, text
146
147RETURN success
Note: See TracBrowser for help on using the repository browser.