Remove all hardcode string to En.rc

from misc.c, move.c pause.c, prompt.c

svn path=/trunk/; revision=14867
This commit is contained in:
Magnus Olsen 2005-04-30 11:16:47 +00:00
parent b8bccfb8b4
commit fcedc0bf07
6 changed files with 144 additions and 64 deletions

View file

@ -289,6 +289,52 @@ STRING_MEMMORY_HELP2, "\n %12s%% memory load.\n\n \
%13s bytes total virtual memory.\n \
%13s bytes available virtual memory.\n"
STRING_MISC_HELP1, "Press a key to continue...\n"
STRING_MOVE_HELP1, "Overwrite %s (Yes/No/All)? "
STRING_MOVE_HELP2, "Moves files and renames files and directories.\n\n \
To move one or more files:\n \
MOVE [/N][drive:][path]filename1[,...] destination\n\n \
To rename a directory:\n \
MOVE [/N][drive:][path]dirname1 dirname2\n\n \
[drive:][path]filename1 Specifies the location and name of the file\n \
or files you want to move.\n \
/N Nothing. Don everthing but move files or direcories.\n\n \
Current limitations:\n \
- You can't move a file or directory from one drive to another.\n"
STRING_PROMPT_HELP1, "Changes the command prompt.\n\n \
PROMPT [text]\n\n \
text Specifies a new command prompt.\n\n \
Prompt can be made up of normal characters and the following special codes:\n\n \
$A & (Ampersand)\n \
$B | (pipe)\n \
$C ( (Left parenthesis)\n \
$D Current date\n \
$E Escape code (ASCII code 27)\n \
$F ) (Right parenthesis)\n \
$G > (greater-than sign)\n \
$H Backspace (erases previous character)\n \
$L < (less-than sign)\n \
$N Current drive\n \
$P Current drive and path\n \
$Q = (equal sign)\n \
$T Current time\n \
$V OS version number\n \
$_ Carriage return and linefeed\n \
$$ $ (dollar sign)"
STRING_PAUSE_HELP1, "Stops the execution of a batch file and shows the following message:\n \
'Press any key to continue...' or a user defined message.\n\n \
PAUSE [message]"
STRING_PROMPT_HELP2, " $+ Displays the current depth of the directory stack"
STRING_PROMPT_HELP3, "\nType PROMPT without parameters to reset the prompt to the default setting."
STRING_RMDIR_HELP, "Removes a directory.\n\n \
RMDIR [drive:]path\nRD [drive:]path"
@ -349,6 +395,9 @@ STRING_FREE_ERROR2, "unlabeled"
STRING_GOTO_ERROR1, "No label specified for GOTO"
STRING_GOTO_ERROR2, "Label '%s' not found\n"
STRING_MOVE_ERROR1, "[OK]\n"
STRING_MOVE_ERROR2, "[Error]\n"
STRING_PARAM_ERROR, "Required parameter missing\n"
STRING_ERROR_PARAMETERF_ERROR, "Parameter format not correct - %c\n"

View file

@ -27,9 +27,13 @@
*
* 06-Nov-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
* Added PagePrompt() and FilePrompt().
*
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
* Remove all hardcode string to En.rc
*/
#include "precomp.h"
#include "resource.h"
/*
@ -434,8 +438,10 @@ HWND GetConsoleWindow (VOID)
INT PagePrompt (VOID)
{
INPUT_RECORD ir;
WCHAR szMsg[RC_STRING_MAX_SIZE];
ConOutPrintf (_T("Press a key to continue...\n"));
LoadString( GetModuleHandle(NULL), STRING_MISC_HELP1, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPrintf((LPTSTR)szMsg);
RemoveBreakHandler ();
ConInDisable ();
@ -464,6 +470,8 @@ INT FilePromptYN (LPTSTR szFormat, ...)
{
TCHAR szOut[512];
va_list arg_ptr;
WCHAR szMsg[RC_STRING_MAX_SIZE];
// TCHAR cKey = 0;
// LPTSTR szKeys = _T("yna");
@ -484,10 +492,16 @@ INT FilePromptYN (LPTSTR szFormat, ...)
for (p = szIn; _istspace (*p); p++)
;
if (*p == _T('Y'))
return PROMPT_YES;
else if (*p == _T('N'))
return PROMPT_NO;
LoadString( GetModuleHandle(NULL), STRING_CHOICE_OPTION, (LPTSTR) szMsg,sizeof(szMsg));
if (wcsncmp(((WCHAR*) p),&szMsg[0],1)==0)
return PROMPT_YES;
else if (wcsncmp(((WCHAR*) p),&szMsg[1],1)==0)
return PROMPT_NO;
#if 0
else if (*p == _T('\03'))
return PROMPT_BREAK;
@ -533,6 +547,8 @@ INT FilePromptYNA (LPTSTR szFormat, ...)
va_list arg_ptr;
// TCHAR cKey = 0;
// LPTSTR szKeys = _T("yna");
WCHAR szMsg[RC_STRING_MAX_SIZE];
TCHAR szIn[10];
LPTSTR p;
@ -551,12 +567,16 @@ INT FilePromptYNA (LPTSTR szFormat, ...)
for (p = szIn; _istspace (*p); p++)
;
if (*p == _T('Y'))
return PROMPT_YES;
else if (*p == _T('N'))
return PROMPT_NO;
if (*p == _T('A'))
return PROMPT_ALL;
LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, (LPTSTR) szMsg,sizeof(szMsg));
if (wcsncmp(((WCHAR*) p),&szMsg[0],1)==0)
return PROMPT_YES;
else if (wcsncmp(((WCHAR*) p),&szMsg[1],1)==0)
return PROMPT_NO;
else if (wcsncmp( ((WCHAR*) p),&szMsg[2],1)==0)
return PROMPT_ALL;
#if 0
else if (*p == _T('\03'))
return PROMPT_BREAK;

View file

@ -20,9 +20,13 @@
*
* 03-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
* Added "/N" option.
*
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
* Remove all hardcode string to En.rc
*/
#include "precomp.h"
#include "resource.h"
#ifdef INCLUDE_CMD_MOVE
@ -37,8 +41,10 @@ static INT Overwrite (LPTSTR fn)
{
TCHAR inp[10];
LPTSTR p;
WCHAR szMsg[RC_STRING_MAX_SIZE];
ConOutPrintf (_T("Overwrite %s (Yes/No/All)? "), fn);
LoadString( GetModuleHandle(NULL), STRING_MOVE_HELP1, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPrintf ((LPTSTR)szMsg, fn);
ConInString (inp, 10);
_tcsupr (inp);
@ -67,6 +73,7 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
HANDLE hFile;
LPTSTR pszFile;
BOOL bNothing = FALSE;
WCHAR szMsg[RC_STRING_MAX_SIZE];
if (!_tcsncmp (param, _T("/?"), 2))
{
@ -85,20 +92,8 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
" /-Y\n"
"..."));
#else
ConOutPuts (_T("Moves files and renames files and directories.\n\n"
"To move one or more files:\n"
"MOVE [/N][drive:][path]filename1[,...] destination\n"
"\n"
"To rename a directory:\n"
"MOVE [/N][drive:][path]dirname1 dirname2\n"
"\n"
" [drive:][path]filename1 Specifies the location and name of the file\n"
" or files you want to move.\n"
" /N Nothing. Don everthing but move files or direcories.\n"
"\n"
"Current limitations:\n"
" - You can't move a file or directory from one drive to another.\n"
));
LoadString( GetModuleHandle(NULL), STRING_MOVE_HELP2, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPuts ((LPTSTR)szMsg);
#endif
return 0;
}
@ -106,6 +101,8 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
arg = split (param, &argc, FALSE);
nFiles = argc;
LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, (LPTSTR) szMsg,sizeof(szMsg));
/* read options */
for (i = 0; i < argc; i++)
{
@ -117,14 +114,14 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
if (*p == _T('-'))
{
p++;
if (_totupper (*p) == _T('Y'))
if ((WCHAR*) _totupper (*p) == &szMsg[0])
bPrompt = TRUE;
}
else
{
if (_totupper (*p) == _T('Y'))
if ((WCHAR*) _totupper (*p) == &szMsg[0])
bPrompt = FALSE;
else if (_totupper (*p) == _T('N'))
else if ((WCHAR*) _totupper (*p) == &szMsg[1])
bNothing = TRUE;
}
nFiles--;
@ -197,9 +194,11 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
if (!bNothing)
{
if (MoveFile (szSrcPath, szFullDestPath))
ConOutPrintf (_T("[OK]\n"));
LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR1, (LPTSTR) szMsg,sizeof(szMsg));
else
ConOutPrintf (_T("[Error]\n"));
LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR2, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPrintf ((LPTSTR)szMsg);
}
}
else
@ -219,9 +218,10 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
if (!bNothing)
{
if (MoveFile (szSrcPath, szDestPath))
ConOutPrintf (_T("[OK]\n"));
LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR1, (LPTSTR) szMsg,sizeof(szMsg));
else
ConOutPrintf (_T("[Error]\n"));
LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR2, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPrintf ((LPTSTR)szMsg);
}
}
}
@ -238,9 +238,10 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
if (!bNothing)
{
if (MoveFile (szSrcPath, szFullDestPath))
ConOutPrintf (_T("[OK]\n"));
else
ConOutPrintf (_T("[Error]\n"));
LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR1, (LPTSTR) szMsg,sizeof(szMsg));
else
LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR2, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPrintf ((LPTSTR)szMsg);
}
}
}

View file

@ -18,6 +18,7 @@
*/
#include "precomp.h"
#include "resource.h"
#ifdef INCLUDE_CMD_PAUSE
@ -29,19 +30,24 @@
*
* ?? Extend to include functionality of CHOICE if switch chars
* specified.
*
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
* Remove all hardcode string to En.rc
*/
INT cmd_pause (LPTSTR cmd, LPTSTR param)
{
WCHAR szMsg[RC_STRING_MAX_SIZE];
#ifdef _DEBUG
DebugPrintf (_T("cmd_pause: \'%s\' : \'%s\')\n"), cmd, param);
#endif
if (!_tcsncmp (param, _T("/?"), 2))
{
ConOutPuts (_T("Stops the execution of a batch file and shows the following message:\n"
"\"Press any key to continue...\" or a user defined message.\n\n"
"PAUSE [message]"));
LoadString( GetModuleHandle(NULL), STRING_PAUSE_HELP1, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPuts ((LPTSTR)szMsg);
return 0;
}

View file

@ -42,8 +42,12 @@
*
* 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
* Fixed Win32 environment handling.
*
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
* Remove all hardcode string to En.rc
*/
#include "precomp.h"
#include "resource.h"
/*
* print the command-line prompt
@ -178,32 +182,19 @@ VOID PrintPrompt(VOID)
INT cmd_prompt (LPTSTR cmd, LPTSTR param)
{
WCHAR szMsg[RC_STRING_MAX_SIZE];
if (!_tcsncmp (param, _T("/?"), 2))
{
ConOutPuts (_T("Changes the command prompt.\n\n"
"PROMPT [text]\n\n"
" text Specifies a new command prompt.\n\n"
"Prompt can be made up of normal characters and the following special codes:\n\n"
" $A & (Ampersand)\n"
" $B | (pipe)\n"
" $C ( (Left parenthesis)\n"
" $D Current date\n"
" $E Escape code (ASCII code 27)\n"
" $F ) (Right parenthesis)\n"
" $G > (greater-than sign)\n"
" $H Backspace (erases previous character)\n"
" $L < (less-than sign)\n"
" $N Current drive\n"
" $P Current drive and path\n"
" $Q = (equal sign)\n"
" $T Current time\n"
" $V OS version number\n"
" $_ Carriage return and linefeed\n"
" $$ $ (dollar sign)"));
LoadString( GetModuleHandle(NULL), STRING_PROMPT_HELP1, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPuts ((LPTSTR)szMsg);
#ifdef FEATURE_DIRECTORY_STACK
ConOutPuts (_T(" $+ Displays the current depth of the directory stack"));
LoadString( GetModuleHandle(NULL), STRING_PROMPT_HELP2, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPuts ((LPTSTR)szMsg);
#endif
ConOutPuts (_T("\nType PROMPT without parameters to reset the prompt to the default setting."));
LoadString( GetModuleHandle(NULL), STRING_PROMPT_HELP3, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPuts ((LPTSTR)szMsg);
return 0;
}

View file

@ -61,7 +61,9 @@
#define STRING_FREE_ERROR2 339
#define STRING_GOTO_ERROR1 340
#define STRING_GOTO_ERROR2 341
#define STRING_PARAM_ERROR 342
#define STRING_MOVE_ERROR1 342
#define STRING_MOVE_ERROR2 343
#define STRING_PARAM_ERROR 344
#define STRING_ATTRIB_HELP 600
@ -137,9 +139,20 @@
#define STRING_MEMMORY_HELP1 659
#define STRING_MEMMORY_HELP2 660
#define STRING_RMDIR_HELP 661
#define STRING_MISC_HELP1 661
#define STRING_REM_HELP 662
#define STRING_MOVE_HELP1 662
#define STRING_MOVE_HELP2 663
#define STRING_PAUSE_HELP1 664
#define STRING_PROMPT_HELP1 665
#define STRING_PROMPT_HELP2 666
#define STRING_PROMPT_HELP3 667
#define STRING_RMDIR_HELP 668
#define STRING_REM_HELP 669