| 1 | /*:VRX         NLVGetMessage | 
|---|
| 2 | */ | 
|---|
| 3 | NLVGetMessage: 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 |  | 
|---|
| 37 | RETURN message | 
|---|
| 38 |  | 
|---|
| 39 | /*:VRX         NLVSetText | 
|---|
| 40 | */ | 
|---|
| 41 | /* | 
|---|
| 42 | * Sets the specified property of the specified control to the specified | 
|---|
| 43 | * message text. | 
|---|
| 44 | */ | 
|---|
| 45 | NLVSetText: 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 |  | 
|---|
| 57 | RETURN success | 
|---|
| 58 |  | 
|---|
| 59 | /*:VRX */ | 
|---|
| 60 | NLVSetup: 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 |  | 
|---|
| 72 | filestem = VRParseFileName( execPath, "N")'_' | 
|---|
| 73 | say '  NLV filestem = "'filestem'"' | 
|---|
| 74 |  | 
|---|
| 75 | /* First, figure out what language/message file to use. | 
|---|
| 76 | */ | 
|---|
| 77 | Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT')) | 
|---|
| 78 | SELECT | 
|---|
| 79 | WHEN Syslang == 'ZH_TW' THEN nlv = 'tw' | 
|---|
| 80 | WHEN Syslang == 'ZH_CN' THEN nlv = 'cx' | 
|---|
| 81 | OTHERWISE PARSE VAR Syslang nlv '_' . | 
|---|
| 82 | END | 
|---|
| 83 |  | 
|---|
| 84 | /* Find the language file */ | 
|---|
| 85 | select | 
|---|
| 86 | when STREAM( execDir'\'filestem||nlv'.msg', 'C', 'QUERY EXISTS') \= '' then do | 
|---|
| 87 | say "  Found NLV file directly!" | 
|---|
| 88 | settings.!messages = execdir'\'filestem||nlv'.msg' | 
|---|
| 89 | settings.!helpfile = execdir'\'filestem||nlv'.hlp' | 
|---|
| 90 | end | 
|---|
| 91 | when SysSearchPath('DPATH', filestem||nlv'.msg') \= '' THEN DO | 
|---|
| 92 | execDir = VRParseFileName(SysSearchPath('DPATH', filestem||nlv'.msg'),"DP") | 
|---|
| 93 | say "  Found NLV file via DPATH" | 
|---|
| 94 | settings.!messages = execdir'\'filestem||nlv'.msg' | 
|---|
| 95 | settings.!helpfile = execdir'\'filestem||nlv'.hlp' | 
|---|
| 96 | end | 
|---|
| 97 | otherwise do | 
|---|
| 98 | /* Added by Herwig Bauernfeind */ | 
|---|
| 99 | say "  Searching subdirectories" | 
|---|
| 100 | ok = SysFileTree(execDir'\'filestem||nlv'.msg',nlvmsg.,'FOS') | 
|---|
| 101 | if nlvmsg.0 = 1 then do | 
|---|
| 102 | say "  Found NLV file in subdirectory" | 
|---|
| 103 | settings.!messages = VRParseFilename(nlvmsg.1,"DPN")'.msg' | 
|---|
| 104 | settings.!helpfile = VRParseFilename(nlvmsg.1,"DPN")'.hlp' | 
|---|
| 105 | say "  Adding NLV file path to DPATH" | 
|---|
| 106 | OldDPATH = value("DPATH",,"OS2ENVIRONMENT") | 
|---|
| 107 | ok = value("DPATH",VRParseFilename(nlvmsg.1,"DP")';'OldDPATH,"OS2ENVIRONMENT") | 
|---|
| 108 | say "  DPATH="value("DPATH",,"OS2ENVIRONMENT") | 
|---|
| 109 | /* End addition by Herwig Bauernfeind */ | 
|---|
| 110 | end | 
|---|
| 111 | else do | 
|---|
| 112 | say "  Fallback to English" | 
|---|
| 113 | if STREAM( execDir'\'filestem||'en.msg', 'C', 'QUERY EXISTS') = '' then do | 
|---|
| 114 | say "  Found English via DPATH" | 
|---|
| 115 | execDir = VRParseFileName(SysSearchPath('DPATH', filestem||'en.msg'),"DP") | 
|---|
| 116 | end | 
|---|
| 117 | settings.!messages = execDir'\'filestem||'en.msg' | 
|---|
| 118 | settings.!helpfile = execDir'\'filestem||'en.hlp' | 
|---|
| 119 | end | 
|---|
| 120 | end | 
|---|
| 121 | end | 
|---|
| 122 |  | 
|---|
| 123 | /* In case the message file exists but not the help file */ | 
|---|
| 124 | if STREAM( settings.!helpfile , 'C', 'QUERY EXISTS') = "" then do | 
|---|
| 125 | settings.!helpfile = execDir'\'filestem||'en.hlp' | 
|---|
| 126 | end | 
|---|
| 127 |  | 
|---|
| 128 | IF options.!debug == 1 THEN SAY '  NLVMessageFile = "'settings.!messages'"' | 
|---|
| 129 | IF options.!debug == 1 THEN SAY '  NLVHelpFile    = "'settings.!helpfile'"' | 
|---|
| 130 |  | 
|---|
| 131 | IF options.!debug == 1 THEN SAY 'NLVSetup() done' | 
|---|
| 132 | RETURN | 
|---|