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 '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 = VRParseFileName( execPath, "DP")
|
---|
15 | say ' NLV execDir = "'execDir'"'
|
---|
16 |
|
---|
17 | filestem = VRParseFileName( execPath, "N")'_'
|
---|
18 | say ' NLV filestem = "'filestem'"'
|
---|
19 |
|
---|
20 | /* First, figure out what language/message file to use.
|
---|
21 | */
|
---|
22 | Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT'))
|
---|
23 | SELECT
|
---|
24 | WHEN Syslang == 'ZH_TW' THEN nlv = 'tw'
|
---|
25 | WHEN Syslang == 'ZH_CN' THEN nlv = 'cx'
|
---|
26 | OTHERWISE PARSE VAR Syslang nlv '_' .
|
---|
27 | END
|
---|
28 |
|
---|
29 | /* Find the language file */
|
---|
30 | select
|
---|
31 | when STREAM( execDir'\'filestem||nlv'.msg', 'C', 'QUERY EXISTS') \= '' then do
|
---|
32 | say " Found NLV file directly!"
|
---|
33 | settings.!messages = execdir'\'filestem||nlv'.msg'
|
---|
34 | settings.!helpfile = execdir'\'filestem||nlv'.hlp'
|
---|
35 | end
|
---|
36 | when SysSearchPath('DPATH', filestem||nlv'.msg') \= '' THEN DO
|
---|
37 | execDir = VRParseFileName(SysSearchPath('DPATH', filestem||nlv'.msg'),"DP")
|
---|
38 | say " Found NLV file via DPATH"
|
---|
39 | settings.!messages = execdir'\'filestem||nlv'.msg'
|
---|
40 | settings.!helpfile = execdir'\'filestem||nlv'.hlp'
|
---|
41 | end
|
---|
42 | otherwise do
|
---|
43 | /* Added by Herwig Bauernfeind */
|
---|
44 | say " Searching subdirectories"
|
---|
45 | ok = SysFileTree(execDir'\'filestem||nlv'.msg',nlvmsg.,'FOS')
|
---|
46 | if nlvmsg.0 = 1 then do
|
---|
47 | say " Found NLV file in subdirectory"
|
---|
48 | settings.!messages = VRParseFilename(nlvmsg.1,"DPN")'.msg'
|
---|
49 | settings.!helpfile = VRParseFilename(nlvmsg.1,"DPN")'.hlp'
|
---|
50 | say " Adding NLV file path to DPATH"
|
---|
51 | OldDPATH = value("DPATH",,"OS2ENVIRONMENT")
|
---|
52 | ok = value("DPATH",VRParseFilename(nlvmsg.1,"DP")';'OldDPATH,"OS2ENVIRONMENT")
|
---|
53 | say " DPATH="value("DPATH",,"OS2ENVIRONMENT")
|
---|
54 | /* End addition by Herwig Bauernfeind */
|
---|
55 | end
|
---|
56 | else do
|
---|
57 | say " Fallback to English"
|
---|
58 | if STREAM( execDir'\'filestem||'en.msg', 'C', 'QUERY EXISTS') = '' then do
|
---|
59 | say " Found English via DPATH"
|
---|
60 | execDir = VRParseFileName(SysSearchPath('DPATH', filestem||'en.msg'),"DP")
|
---|
61 | end
|
---|
62 | settings.!messages = execDir'\'filestem||'en.msg'
|
---|
63 | settings.!helpfile = execDir'\'filestem||'en.hlp'
|
---|
64 | end
|
---|
65 | end
|
---|
66 | end
|
---|
67 |
|
---|
68 | /* In case the message file exists but not the help file */
|
---|
69 | if STREAM( settings.!helpfile , 'C', 'QUERY EXISTS') = "" then do
|
---|
70 | settings.!helpfile = execDir'\'filestem||'en.hlp'
|
---|
71 | end
|
---|
72 |
|
---|
73 | IF options.!debug == 1 THEN SAY ' NLVMessageFile = "'settings.!messages'"'
|
---|
74 | IF options.!debug == 1 THEN SAY ' NLVHelpFile = "'settings.!helpfile'"'
|
---|
75 |
|
---|
76 | IF options.!debug == 1 THEN SAY 'NLVSetup() done'
|
---|
77 | RETURN
|
---|
78 |
|
---|
79 | /*:VRX NLVGetMessage
|
---|
80 | */
|
---|
81 | NLVGetMessage: PROCEDURE EXPOSE settings. options. fs.
|
---|
82 |
|
---|
83 | msgfile = settings.!messages
|
---|
84 | msgnum = ARG( 1 )
|
---|
85 |
|
---|
86 | IF msgnum == '' THEN RETURN ''
|
---|
87 |
|
---|
88 | SELECT
|
---|
89 | WHEN ARG() == 2 THEN
|
---|
90 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2) )
|
---|
91 | WHEN ARG() == 3 THEN
|
---|
92 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3) )
|
---|
93 | WHEN ARG() == 4 THEN
|
---|
94 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4) )
|
---|
95 | WHEN ARG() == 5 THEN
|
---|
96 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5) )
|
---|
97 | WHEN ARG() == 6 THEN
|
---|
98 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6) )
|
---|
99 | WHEN ARG() == 7 THEN
|
---|
100 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7) )
|
---|
101 | WHEN ARG() == 8 THEN
|
---|
102 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8) )
|
---|
103 | WHEN ARG() == 9 THEN
|
---|
104 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9) )
|
---|
105 | WHEN ARG() == 10 THEN
|
---|
106 | msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10) )
|
---|
107 | OTHERWISE
|
---|
108 | msgtxt = SysGetMessage( msgnum, msgfile )
|
---|
109 | END
|
---|
110 |
|
---|
111 | PARSE VAR msgtxt message '0D'x .
|
---|
112 |
|
---|
113 | IF translate(SUBSTR( message, 1, 4 )) == 'SYS0' THEN message = ''
|
---|
114 |
|
---|
115 | RETURN message
|
---|
116 |
|
---|
117 | /*:VRX NLVSetText
|
---|
118 | */
|
---|
119 | /*
|
---|
120 | * Sets the specified property of the specified control to the specified
|
---|
121 | * message text.
|
---|
122 | */
|
---|
123 | NLVSetText: PROCEDURE EXPOSE settings. options. fs.
|
---|
124 | PARSE ARG control, property, message, substitution
|
---|
125 |
|
---|
126 | success = 1
|
---|
127 | IF substitution == '' THEN
|
---|
128 | text = NLVGetMessage( message )
|
---|
129 | ELSE
|
---|
130 | text = NLVGetMessage( message, substitution )
|
---|
131 |
|
---|
132 | IF text == '' THEN success = 0
|
---|
133 | ELSE CALL VRSet control, property, text
|
---|
134 |
|
---|
135 | RETURN success
|
---|