[348] | 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
|
---|
[361] | 14 | execDir = translate(VRParseFileName( execPath, "DP"))
|
---|
| 15 | parse var execDir srchroot '\BIN'
|
---|
| 16 |
|
---|
[348] | 17 | say ' NLV execDir = "'execDir'"'
|
---|
[361] | 18 | say ' NLV srchroot = "'srchRoot'"'
|
---|
[348] | 19 |
|
---|
| 20 | filestem = VRParseFileName( execPath, "N")'_'
|
---|
| 21 | if translate(filestem) = "EVFSGUI_" then filestem = "evfsi_"
|
---|
| 22 | say ' NLV filestem = "'filestem'"'
|
---|
| 23 |
|
---|
[361] | 24 | /* First, figure out what language/message file to use */
|
---|
[348] | 25 | Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT'))
|
---|
| 26 | SELECT
|
---|
[361] | 27 | WHEN Syslang == 'ZH_TW' THEN nlv = 'TW'
|
---|
| 28 | WHEN Syslang == 'ZH_CN' THEN nlv = 'CX'
|
---|
[348] | 29 | OTHERWISE PARSE VAR Syslang nlv '_' .
|
---|
| 30 | END
|
---|
| 31 |
|
---|
[361] | 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
|
---|
[348] | 59 | end
|
---|
[361] | 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"
|
---|
[450] | 71 | NLVFile = VRParseFilename(nlvmsg.1,"DPN")'.'Suffix
|
---|
[361] | 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
|
---|
[348] | 76 | end
|
---|
[361] | 77 | else say " NLV "Suffix" file not found in subdirectories!"
|
---|
[348] | 78 | end
|
---|
| 79 | end
|
---|
[361] | 80 | if NLVSrchDone = 0 then do /* Fallback to English */
|
---|
[410] | 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
|
---|
[361] | 85 | else do
|
---|
| 86 | say " NLV "Suffix" File not found, falling back to EN."
|
---|
| 87 | nlv = "EN"
|
---|
[410] | 88 | /* Now we repeat the whole procedure to find the EN file */
|
---|
[361] | 89 | end
|
---|
| 90 | end
|
---|
| 91 | end
|
---|
| 92 | say time()' NLVSearch() done, returning "'NLVFile'"'
|
---|
| 93 | return NLVFile
|
---|
[348] | 94 |
|
---|
| 95 | /*:VRX NLVGetMessage
|
---|
| 96 | */
|
---|
| 97 | NLVGetMessage: PROCEDURE EXPOSE settings. options. fs.
|
---|
| 98 |
|
---|
| 99 | msgfile = settings.!messages
|
---|
| 100 | msgnum = ARG( 1 )
|
---|
| 101 |
|
---|
[410] | 102 | IF msgfile == '' THEN RETURN ''
|
---|
[348] | 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 |
|
---|
[450] | 130 | IF translate(SUBSTR( message, 1, 4 )) == 'SYS0' THEN message = '[Missing message 'msgnum'!]'
|
---|
[348] | 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
|
---|