/*:VRX NLVSetup */ NLVSetup: PROCEDURE EXPOSE settings. options. /* This subroutine is (c) by Alex Taylor, portions (c) Herwig Bauernfeind * Sets all UI text from the message file. Any string that can't be loaded * will default to the built-in English. */ IF options.!debug == 1 THEN SAY time()' NLVSetup() started' IF options.!debug == 1 THEN SAY ' NLVSetup() is (c) Alex Taylor, portions (c) Herwig Bauernfeind' execPath = VRGet("Application", "Program") if execPath = "" then parse source . . execPath execDir = translate(VRParseFileName( execPath, "DP")) parse var execDir srchroot '\BIN' say ' NLV execDir = "'execDir'"' say ' NLV srchroot = "'srchRoot'"' filestem = VRParseFileName( execPath, "N") if translate(filestem) = "EVFSGUI" then filestem = "evfsi_" else filestem = SUBSTR( filestem, 1, 6, '_' ) say ' NLV filestem = "'filestem'"' /* First, figure out what language/message file to use */ Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT')) SELECT WHEN Syslang == 'ZH_TW' THEN nlv = 'TW' WHEN Syslang == 'ZH_CN' THEN nlv = 'CX' OTHERWISE PARSE VAR Syslang nlv '_' . END /* Find the messagefile and helpfile */ settings.!messages = NLVsearch(nlv,'LANG','MSG','DPATH') settings.!helpfile = NLVsearch(nlv,'HELP','HLP','HELP') IF options.!debug == 1 THEN SAY ' NLV MessageFile = "'settings.!messages'"' IF options.!debug == 1 THEN SAY ' NLV HelpFile = "'settings.!helpfile'"' IF options.!debug == 1 THEN SAY time()' NLVSetup() done' RETURN /*:VRX NLVSearch */ NLVSearch: procedure expose filestem execdir srchroot nlv = arg(1) SubDir = arg(2) Suffix = arg(3) PathVar = arg(4) say time()" NLVSearch() started" NLVSrchDone = 0 NLVFile = "" do until NLVSrchDone = 1 say ' NLV 'Suffix' file = "'filestem||nlv'.'Suffix'"' select when VRFileExists(srchRoot'\'SubDir'\'filestem||nlv'.'Suffix) then do say " NLV "Suffix" file found directly!" NLVFile = strip(srchRoot'\'SubDir'\'filestem||nlv'.'Suffix,'L','\') NLVSrchDone = 1 end when SysSearchPath(PathVar, filestem||nlv'.'Suffix) \= '' then do execDir = VRParseFileName(SysSearchPath(PathVar, filestem||nlv'.'Suffix),"DP") say " NLV "Suffix" file found via "PathVar NLVFile = strip(execdir'\'filestem||nlv'.'Suffix,'L','\') NLVSrchDone = 1 end otherwise do say " Searching subdirectories" ok = SysFileTree(srchRoot'\'filestem||nlv'.'Suffix,nlvmsg.,'FOS') if nlvmsg.0 = 1 then do say " Found NLV "Suffix" file in subdirectory" NLVFile = VRParseFilename(nlvmsg.1,"DPN")'.'Suffix say " Adding NLV "Suffix" path to "PathVar OldPathVar = value(PathVar,,"OS2ENVIRONMENT") ok = value(PathVar,VRParseFilename(nlvmsg.1,"DP")';'OldPathVar,"OS2ENVIRONMENT") NLVSrchDone = 1 end else say " NLV "Suffix" file not found in subdirectories!" end end if NLVSrchDone = 0 then do /* Fallback to English */ if nlv = "EN" then do NLVSrchDone = 1 /* We give up and leave */ id = VRMessage( "", "Could not find a valid language file!", "NLV Setup Error", "E", ) /* We will leave without a valid NLV file here! */ end else do say " NLV "Suffix" File not found, falling back to EN." nlv = "EN" /* Now we repeat the whole procedure to find the EN file */ end end end say time()' NLVSearch() done, returning "'NLVFile'"' return NLVFile /*:VRX NLVGetMessage */ NLVGetMessage: PROCEDURE EXPOSE settings. options. fs. msgfile = settings.!messages msgnum = ARG( 1 ) IF msgfile == '' THEN RETURN '' IF msgnum == '' THEN RETURN '' SELECT WHEN ARG() == 2 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2) ) WHEN ARG() == 3 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3) ) WHEN ARG() == 4 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4) ) WHEN ARG() == 5 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5) ) WHEN ARG() == 6 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6) ) WHEN ARG() == 7 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(3), ARG(4), ARG(5), ARG(6), ARG(7) ) WHEN ARG() == 8 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8) ) WHEN ARG() == 9 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9) ) WHEN ARG() == 10 THEN msgtxt = SysGetMessage( msgnum, msgfile, ARG(2), ARG(2), ARG(4), ARG(5), ARG(6), ARG(7), ARG(8), ARG(9), ARG(10) ) OTHERWISE msgtxt = SysGetMessage( msgnum, msgfile ) END PARSE VAR msgtxt message '0D'x . IF translate(SUBSTR( message, 1, 4 )) == 'SYS0' THEN message = '[Missing message 'msgnum'!]' RETURN message /*:VRX NLVSetText */ /* * Sets the specified property of the specified control to the specified * message text. */ NLVSetText: PROCEDURE EXPOSE settings. options. fs. PARSE ARG control, property, message, substitution success = 1 IF substitution == '' THEN text = NLVGetMessage( message ) ELSE text = NLVGetMessage( message, substitution ) IF text == '' THEN success = 0 ELSE CALL VRSet control, property, text RETURN success