1 | /*:VRX NLVSetup
|
---|
2 | */
|
---|
3 | NLVSetup: 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'
|
---|
40 | RETURN
|
---|
41 |
|
---|
42 | /*:VRX NLVSearch
|
---|
43 | */
|
---|
44 | NLVSearch: 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 do
|
---|
82 | NLVSrchDone = 1 /* We give up and leave */
|
---|
83 | /* We will leave without a valid NLV file here! */
|
---|
84 | end
|
---|
85 | else do
|
---|
86 | say " NLV "Suffix" File not found, falling back to EN."
|
---|
87 | nlv = "EN"
|
---|
88 | /* Now we repeat the whole procedure to find the EN file */
|
---|
89 | end
|
---|
90 | end
|
---|
91 | end
|
---|
92 | say time()' NLVSearch() done, returning "'NLVFile'"'
|
---|
93 | return NLVFile
|
---|
94 |
|
---|
95 | /*:VRX NLVGetMessage
|
---|
96 | */
|
---|
97 | NLVGetMessage: PROCEDURE EXPOSE settings. options. fs.
|
---|
98 |
|
---|
99 | msgfile = settings.!messages
|
---|
100 | msgnum = ARG( 1 )
|
---|
101 |
|
---|
102 | IF msgfile == '' THEN RETURN ''
|
---|
103 | IF msgnum == '' THEN RETURN ''
|
---|
104 |
|
---|
105 | SELECT
|
---|
106 | WHEN ARG() == 2 THEN
|
---|
107 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2) )
|
---|
108 | WHEN ARG() == 3 THEN
|
---|
109 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3) )
|
---|
110 | WHEN ARG() == 4 THEN
|
---|
111 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4) )
|
---|
112 | WHEN ARG() == 5 THEN
|
---|
113 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5) )
|
---|
114 | WHEN ARG() == 6 THEN
|
---|
115 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6) )
|
---|
116 | WHEN ARG() == 7 THEN
|
---|
117 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7) )
|
---|
118 | WHEN ARG() == 8 THEN
|
---|
119 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8) )
|
---|
120 | WHEN ARG() == 9 THEN
|
---|
121 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9) )
|
---|
122 | WHEN ARG() == 10 THEN
|
---|
123 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10) )
|
---|
124 | OTHERWISE
|
---|
125 | msgtxt = SysGetMessage( msgnum, msgfile )
|
---|
126 | END
|
---|
127 |
|
---|
128 | PARSE VAR msgtxt message '0D'x .
|
---|
129 |
|
---|
130 | IF translate(SUBSTR( message, 1, 4 )) == 'SYS0' THEN message = ''
|
---|
131 |
|
---|
132 | RETURN message
|
---|
133 |
|
---|
134 | /*:VRX NLVSetText
|
---|
135 | */
|
---|
136 | /*
|
---|
137 | * Sets the specified property of the specified control to the specified
|
---|
138 | * message text.
|
---|
139 | */
|
---|
140 | NLVSetText: PROCEDURE EXPOSE settings. options. fs.
|
---|
141 | PARSE ARG control, property, message, substitution
|
---|
142 |
|
---|
143 | success = 1
|
---|
144 | IF substitution == '' THEN
|
---|
145 | text = NLVGetMessage( message )
|
---|
146 | ELSE
|
---|
147 | text = NLVGetMessage( message, substitution )
|
---|
148 |
|
---|
149 | IF text == '' THEN success = 0
|
---|
150 | ELSE CALL VRSet control, property, text
|
---|
151 |
|
---|
152 | RETURN success
|
---|