source: branches/guitools-1.0/shared/nlv.vrs@ 333

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

GUI-Tools: Fix problem in smbusers

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