+implemented dir command; *polished document.
This commit is contained in:
parent
d8d58634f4
commit
4063ef1cea
5
HISTORY
5
HISTORY
@ -1,6 +1,8 @@
|
|||||||
Dec. 30 2015
|
Dec. 30 2015
|
||||||
Improved error handling with sub routine and class
|
Improved error handling with sub routine and class
|
||||||
|
Implemented DIR command
|
||||||
Polished code
|
Polished code
|
||||||
|
Polished document
|
||||||
|
|
||||||
Dec. 29 2015
|
Dec. 29 2015
|
||||||
Fixed a multiple disposing bug with expression calculation
|
Fixed a multiple disposing bug with expression calculation
|
||||||
@ -247,7 +249,8 @@ Improved sub routine
|
|||||||
Sep. 2 2015
|
Sep. 2 2015
|
||||||
Added sub routine type insurance
|
Added sub routine type insurance
|
||||||
Prompted more friendly dummy function message
|
Prompted more friendly dummy function message
|
||||||
Polished code and document
|
Polished code
|
||||||
|
Polished document
|
||||||
|
|
||||||
Sep. 1 2015
|
Sep. 1 2015
|
||||||
Added support for user customized sub routine by DEF/ENDDEF
|
Added support for user customized sub routine by DEF/ENDDEF
|
||||||
|
Binary file not shown.
30
shell/main.c
30
shell/main.c
@ -656,6 +656,18 @@ static void _kill_program(const char* path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _list_directory(const char* path) {
|
||||||
|
char line[_MAX_LINE_LENGTH];
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
if(path && *path) sprintf(line, "dir %s", path);
|
||||||
|
else sprintf(line, "dir");
|
||||||
|
#else /* _MSC_VER */
|
||||||
|
if(path && *path) sprintf(line, "ls %s", path);
|
||||||
|
else sprintf(line, "ls");
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
system(line);
|
||||||
|
}
|
||||||
|
|
||||||
static void _show_tip(void) {
|
static void _show_tip(void) {
|
||||||
_printf("MY-BASIC Interpreter Shell - %s\n", mb_ver_string());
|
_printf("MY-BASIC Interpreter Shell - %s\n", mb_ver_string());
|
||||||
_printf("Copyright (C) 2011 - 2016 Wang Renxin. All Rights Reserved.\n");
|
_printf("Copyright (C) 2011 - 2016 Wang Renxin. All Rights Reserved.\n");
|
||||||
@ -664,11 +676,16 @@ static void _show_tip(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _show_help(void) {
|
static void _show_help(void) {
|
||||||
_printf("Parameters:\n");
|
_printf("Modes:\n");
|
||||||
_printf(" %s - Start interactive mode without arguments\n", _BIN_FILE_NAME);
|
_printf(" %s - Start interactive mode without arguments\n", _BIN_FILE_NAME);
|
||||||
_printf(" %s *.* - Load and run a file\n", _BIN_FILE_NAME);
|
_printf(" %s *.* - Load and run a file\n", _BIN_FILE_NAME);
|
||||||
_printf(" %s -e \"expr\" - Evaluate an expression directly\n", _BIN_FILE_NAME);
|
_printf(" %s -e \"expr\" - Evaluate an expression directly\n", _BIN_FILE_NAME);
|
||||||
|
_printf("\n");
|
||||||
|
_printf("Options:\n");
|
||||||
|
_printf(" -p n - Set memory pool threashold size, n is size in bytes\n");
|
||||||
|
_printf("\n");
|
||||||
_printf("Interactive commands:\n");
|
_printf("Interactive commands:\n");
|
||||||
|
_printf(" HELP - View help information\n");
|
||||||
_printf(" CLS - Clear screen\n");
|
_printf(" CLS - Clear screen\n");
|
||||||
_printf(" NEW - Clear current program\n");
|
_printf(" NEW - Clear current program\n");
|
||||||
_printf(" RUN - Run current program\n");
|
_printf(" RUN - Run current program\n");
|
||||||
@ -677,14 +694,16 @@ static void _show_help(void) {
|
|||||||
_printf(" Usage: LIST [l [n]], l is start line number, n is line count\n");
|
_printf(" Usage: LIST [l [n]], l is start line number, n is line count\n");
|
||||||
_printf(" EDIT - Edit (modify/insert/remove) a line in current program\n");
|
_printf(" EDIT - Edit (modify/insert/remove) a line in current program\n");
|
||||||
_printf(" Usage: EDIT n, n is line number\n");
|
_printf(" Usage: EDIT n, n is line number\n");
|
||||||
_printf(" EDIT -I n, insert a line before a given line, n is line number\n");
|
_printf(" EDIT -i n, insert a line before a given line, n is line number\n");
|
||||||
_printf(" EDIT -R n, remove a line, n is line number\n");
|
_printf(" EDIT -r n, remove a line, n is line number\n");
|
||||||
_printf(" LOAD - Load a file as current program\n");
|
_printf(" LOAD - Load a file as current program\n");
|
||||||
_printf(" Usage: LOAD *.*\n");
|
_printf(" Usage: LOAD *.*\n");
|
||||||
_printf(" SAVE - Save current program to a file\n");
|
_printf(" SAVE - Save current program to a file\n");
|
||||||
_printf(" Usage: SAVE *.*\n");
|
_printf(" Usage: SAVE *.*\n");
|
||||||
_printf(" KILL - Delete a file\n");
|
_printf(" KILL - Delete a file\n");
|
||||||
_printf(" Usage: KILL *.*\n");
|
_printf(" Usage: KILL *.*\n");
|
||||||
|
_printf(" DIR - List a directory\n");
|
||||||
|
_printf(" Usage: DIR [p], p is a directory path\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _do_line(void) {
|
static int _do_line(void) {
|
||||||
@ -750,6 +769,9 @@ static int _do_line(void) {
|
|||||||
} else if(_str_eq(line, "KILL")) {
|
} else if(_str_eq(line, "KILL")) {
|
||||||
char* path = line + strlen(line) + 1;
|
char* path = line + strlen(line) + 1;
|
||||||
_kill_program(path);
|
_kill_program(path);
|
||||||
|
} else if(_str_eq(line, "DIR")) {
|
||||||
|
char* path = line + strlen(line) + 1;
|
||||||
|
_list_directory(path);
|
||||||
} else {
|
} else {
|
||||||
_append_line(c, dup);
|
_append_line(c, dup);
|
||||||
}
|
}
|
||||||
@ -834,7 +856,7 @@ static bool_t _process_parameters(int argc, char* argv[]) {
|
|||||||
prog = argv[++i];
|
prog = argv[++i];
|
||||||
#if _USE_MEM_POOL
|
#if _USE_MEM_POOL
|
||||||
} else if(!memcmp(argv[i] + 1, "p", 1)) {
|
} else if(!memcmp(argv[i] + 1, "p", 1)) {
|
||||||
_CHECK_ARG(argc, i, "-p: Memory pool threashold expected.\n");
|
_CHECK_ARG(argc, i, "-p: Memory pool threashold size expected.\n");
|
||||||
memp = argv[++i];
|
memp = argv[++i];
|
||||||
if(argc > i + 1)
|
if(argc > i + 1)
|
||||||
prog = argv[++i];
|
prog = argv[++i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user