From 3a349f1c2dc93b17e7f82e74475ead6edfc6746e Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Thu, 17 Jun 1999 23:59:07 +0000 Subject: [PATCH] See ChangeLog entry 19990617-18:55 EDT David G. Holm --- harbour/ChangeLog | 13 ++ harbour/include/set.h | 2 +- harbour/source/rtl/console.c | 12 +- harbour/source/rtl/set.c | 251 ++++++++++++++++++++++++++++++- harbour/tests/working/output.prg | 3 +- 5 files changed, 271 insertions(+), 10 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8f3331240a..cf5ff3a505 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,16 @@ +19990617-18:55 EDT David G. Holm + * include/set.h + - SET DEBUG is numeric, not logical + * source/rtl/console.c + - Added support for SET MARGIN + * source/rtl/set.c + - Added documentation + - Converted HB_SET_DEBUG to numeric + - Added limits of 16 and 4096 to HB_SET_TYPEAHEAD + * tests/working/output.prg + - Removed ADDITIVE from SET PRINTER TO OUTPUT + - Added SET MARGIN TO 5 + 19990617-21:55 CET Eddie Runia * source/rtl/set.c __SETCENTURY in Symbol table instead of SETCENTURY diff --git a/harbour/include/set.h b/harbour/include/set.h index e47a11d306..97a0bad6b1 100644 --- a/harbour/include/set.h +++ b/harbour/include/set.h @@ -87,7 +87,7 @@ typedef struct BOOL HB_SET_CONSOLE; /* Logical */ HB_cursor_enum HB_SET_CURSOR; /* Numeric */ char *HB_SET_DATEFORMAT; /* Character */ - BOOL HB_SET_DEBUG; /* Logical */ + int HB_SET_DEBUG; /* Numeric */ int HB_SET_DECIMALS; /* Numeric */ char *HB_SET_DEFAULT; /* Character */ BOOL HB_SET_DELETED; /* Logical */ diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index d9a108cde8..a316e93069 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -250,11 +250,10 @@ static void hb_altout( char * fpStr, WORD uiLen ) { #ifdef USE_GTAPI hb_gtWriteCon( fpStr, uiLen ); - if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) || hb_set_printhan < 0 ) - hb_gtGetPos( &dev_row, &dev_col ); + hb_gtGetPos( &dev_row, &dev_col ); #else WORD uiCount; - for( uiCount = 0; uiCount < uiLen; uiCount++ ) + for( uiCount = 0; uiCount < uiLen; uiCount++ ) printf( "%c", fpStr[ uiCount ] ); adjust_pos( fpStr, uiLen, &dev_row, &dev_col, hb_max_row(), hb_max_col() ); #endif @@ -324,6 +323,7 @@ void hb_devpos( USHORT row, USHORT col ) } for( count = p_row; count < row; count++ ) write( hb_set_printhan, CrLf, strlen (CrLf) ); if( row > p_row ) p_col = 0; + col += hb_set.HB_SET_MARGIN; for( count = p_col; count < col; count++ ) write( hb_set_printhan, " ", 1 ); p_row = row; p_col = col; @@ -369,11 +369,15 @@ HARBOUR HB_QOUT( void ) #ifdef WINDOWS MessageBox( 0, hb_parc( 1 ), "Harbour", 0 ); #else + int count; hb_altout( CrLf, strlen (CrLf) ); if( hb_set.HB_SET_PRINTER && hb_set_printhan >= 0 ) { p_row++; - p_col=0; + p_col = hb_set.HB_SET_MARGIN; + count = p_col; + while( count-- > 0 ) + write( hb_set_printhan, " ", 1 ); } HB_QQOUT(); #endif diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index 9ddf87bf13..d685b57fd3 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -152,6 +152,14 @@ static int open_handle (char * file_name, BOOL bMode, char * def_ext) return handle; } +/* $DOC$ + * $FUNCNAME$ __SETCENTURY( [ | ] ) --> lPreviousValue + * $ARGUMENTS$ optional or (not case sensitive) + * .T. or "ON" to enable the century setting (4-digit years) + * .F. or "OFF" to disable the century setting (2-digit years) + * $RETURNS$ Either the current or previous century setting as a logical value + * $END$ + */ HARBOUR HB___SETCENTURY (void) { int digit, count, size, y_size, y_start, y_stop; @@ -229,6 +237,235 @@ HARBOUR HB___SETCENTURY (void) } } +/* $DOC$ + * $FUNCNAME$ SET( [, [, ] ] ) --> xPreviousSetting + * $ARGUMENTS$ + * _SET_ALTERNATE | + * If enabled, QOUT() and QQOUT() write to the screen and to + * a file, provided that a file has been opened or created + * with _SET_ALTFILE. If disabled, which is the default, + * QOUT() and QQOUT() only write to the screen (and/or to + * the PRINTFILE). + * _SET_ALTFILE + * When set, creates or opens file to write QOUT() and + * QQOUT() output to. If is TRUE and the file + * already exists, the file is opened and positioned at end + * of file. Otherwise, the file is created. If a file is + * already opened, it is closed before the new file is + * opened or created (even if it is the same file). The + * default file extension is ".txt". There is no default + * file name. + * _SET_BELL | + * When enabled, the bell sounds when the last position of + * a GET is reached and/or when a GET validation fails. + * Disabled by default. + * _SET_CANCEL | + * When enabled, which is the default, pressing Alt+C or + * Ctrl+Break terminates the program. When disabled, both + * keystrokes can be read by INKEY(). Note: SET KEY has + * precedence over SET CANCEL. + * _SET_COLOR + * Sets the current color scheme, using color pairs in the + * sequence ",,,, + * ". Each color pair uses the format + * "/". The color codes are space + * or "N" for black, "B" for blue, "G" for green, "BG" for + * Cyan, "R" for red, "RB" for magenta, "GR" for brown, "W" + * for white, "N+" for gray, "B+" for bright blue, "G+" for + * bright green, "BG+" for bright cyan, "R+" for bright red, + * "RB+" for bright magenta, "GR+" for yellow, and "W+" for + * bright white. Special codes are "I" for inverse video, + * "U" for underline on a monochrome monitor (black on a + * color monitor), and "X" for blank. The default color is + * "W/N,N/W,N,N,N/W". + * _SET_CONFIRM | + * If enabled, an exit key must be pressed to leave a GET. + * If disabled, which is the default, typing past the end + * will leave a GET. + * _SET_CONSOLE | + * If enabled, which is the default, all screen output goes + * to the screen. When disabled, screen output is suppressed + * (Note: This setting does not affect OUTSTD() or OUTERR()). + * _SET_CURSOR + * If enabled, which is the default, the cursor is displayed + * on screen. If disabled, the screen cursor is hidden. + * _SET_DATEFORMAT + * Sets the default date format for display, date input, and + * date conversion. Defaults to American ("mm/dd/yy"). Other + * formats include ANSI ("yy.mm.dd"), British ("dd/mm/yy"), + * French ("dd/mm/yy"), German ("dd.mm.yy"), Italian + * ("dd-mm-yy"), Japan ("yy/mm/dd"), and USA ("mm-dd-yy"). + * SET CENTURY modifies the date format. SET CENTURY ON + * replaces the "y"s with "YYYY". SET CENTURY OFF replaces + * the "y"s with "YY". + * _SET_DEBUG + * When set to 1, pressing Alt+D activates the debugger. + * When set to 0, which is the default, Alt+D can be read + * by INKEY(). + * _SET_DECIMALS + * Sets the number of decimal digits to use when displaying + * printing numeric values when SET FIXED is ON. Defaults to + * 2. If SET FIXED is OFF, then SET DECIMALS is only used to + * determine the number of decimal digits to use after using + * EXP(), LOG(), SQRT(), or division. Other math operations + * may adjust the number of decimal digits that the result + * will display. Note: This never affects the precision of + * a number. Only the display format is affected. + * _SET_DEFAULT + * Sets the default directory in which to open, create and + * check for files. Defaults to the current directory. + * _SET_DELETED | + * If enabled, deleted records will be processed. If + * disabled, which is the default, deleted records will + * be ignored. + * _SET_DELIMCHARS + * Sets the GET delimiter characters. Defaults to "::". + * _SET_DELIMITERS | + * If enabled, GETs are delimited on screen. If disabled, + * which is the default, no GET delimiters are used. + * _SET_DEVICE + * Selects the output device for DEVOUT(). When set to + * "PRINTER", all output is sent to the printer device or + * file set by _SET_PRINTFILE. When set to anything else, + * all output is sent to the screen. Defaults to "SCREEN". + * _SET_EPOCH + * Determines how to handle the conversion of 2-digit years + * to 4 digit years. When a 2-digit year is greater than or + * equal to the year part of the epoch, the century part of + * the epoch is added to the year. When a 2-digit year is + * less than the year part of the epoch, the century part + * of the epoch is incremented and added to the year. The + * default epoch is 1900, which converts all 2-digit years + * to 19xx. Example: If the epoch is set to 1950, 2-digit + * years in the range from 50 to 99 get converted to 19xx + * and 2-digit years in the range 00 to 49 get converted + * to 20xx. + * _SET_ESCAPE | + * When enabled, which is the default, pressing Esc will + * exit a READ. When disabled, pressing Esc during a READ + * is ignored, unless the Esc key has been assigned to a + * function using SET KEY. + * _SET_EVENTMASK + * Determines which events INKEY() will respond to. + * INKEY_MOVE allows mouse movement events. INKEY_LDOWN + * allows the left mouse button down click. INKEY_LUP + * allows the left mouse button up click. INKEY_RDOWN + * allows the right mouse button down click. INKEY_RUP + * allows the right mouse button up clock. INKEY_KEYBOARD + * allows keyboard keystrokes. INKEY_ALL allows all of the + * preceding events. Events may be combined (e.g., using + * INKEY_LDOWN + INKEY_RUP will allow left mouse button + * down clicks and right mouse button up clicks). The + * default is INKEY_KEYBOARD. + * _SET_EXACT | + * When enabled, all string comparisons other than "==" + * exclude trailing spaces when checking for equality. + * When disabled, which is the default, all string + * comparisons other than "==" treat two strings as + * equal if the right hand string is "" or if the right + * hand string is shorter than or the same length as the + * left hand string and all of the characters in the right + * hand string match the corresponding characters in the + * left hand string. + * _SET_EXCLUSIVE | + * When enabled, which is the default, all database files + * are opened in exclusive mode. When disabled, all + * database files are opened in shared mode. Note: The + * EXCLUSIVE and SHARED clauses of the USE command can be + * used to override this setting. + * _SET_EXIT | + * QUESTION: What is this for? Controlling the exit keys + * during a READ? + * _SET_EXTRA | + * QUESTION: If enabled, what happens, provided that a file + * has been opened or created with _SET_EXTRAFILE? If + * disabled, which is the default, what doesn't happen? + * _SET_EXTRAFILE + * QUUESTION: When set, creates or opens file for what + * purpose? If is TRUE and the file already + * exists, the file is opened and positioned at end of + * file. Otherwise, the file is created. If a file is + * already opened, it is closed before the new file is + * opened or created (even if it is the same file). + * _SET_FIXED | + * When enabled, all numeric values will be displayed + * and printed with the number of decimal digits set + * by SET DECIMALS, unless a PICTURE clause is used. + * When disabled, which is the default, the number + * of decimal digits that are displayed depends upon + * a variety of factors. See _SET_DECIMALS for more. + * _SET_INSERT | + * When enabled, characters typed in a GET or MEMOEDIT + * are inserted. When disabled, which is the default, + * characters typed in a GET or MEMOEDIT overwrite. + * Note: This setting can also be toggled between on and + * off by pressing the Insert key during a GET or MEMOEDIT. + * _SET_INTENSITY | + * When enabled, which is the default, GETs and PROMPTs + * are displayed using the enhanced color setting. When + * disabled, GETs and PROMPTs are displayed using the + * standard color setting. + * _SET_MARGIN + * Sets the left margin for all printed output. The default + * value is 0. Note: PCOL() reflects the printer's column + * position including the margin (e.g., SET MARGIN TO 5 + * followed by DEVPOS(5, 10) makes PCOL() return 15). + * _SET_MCENTER | + * If enabled, display PROMPTs centered on the MESSAGE row. + * If disabled, which is the default, display PROMPTS at + * column position 0 on the MESSAGE row. + * _SET_MESSAGE + * If set to 0, which is the default, PROMPTs are always + * suppressed. Otherwise, PROMPTs are displayed on the + * set row. Note: It is not possible to display prompts + * on the top-most screen row, because row 0 is reserved + * for the SCOREBOARD, if enabled. + * _SET_PATH + * Specifies a path of directories to search through to + * locate a file that can't be located in the DEFAULT + * directory. Defaults to no path (""). Directories must + * be separated by a semicolon (e.g., "C:\DATA;C:\MORE"). + * _SET_PRINTER | + * If enabled, QOUT() and QQOUT() write to the screen and to + * a file, provided that a file has been opened or created + * with _SET_ALTFILE. If disabled, which is the default, + * QOUT() and QQOUT() only write to the screen (and/or to + * the ALTFILE). + * _SET_PRINTFILE + * When set, creates or opens file to write QOUT(), QQOUT() + * and DEVOUT() output to. If is TRUE and the + * file already exists, the file is opened and positioned + * at end of file. Otherwise, the file is created. If a + * file is already opened, it is closed before the new file + * is opened or created (even if it is the same file). The + * default file extension is ".prn". The default file name + * is "PRN", which maps to the default printer device. + * _SET_SCOREBOARD | + * When enabled, which is the default, READ and MEMOEDIT + * display status messages on screen row 0. When disabled, + * READ and MEMOEDIT status messages are suppressed. + * _SET_SCROLLBREAK | + * QUESTION: What is this flag for? + * _SET_SOFTSEEK | + * When enabled, a SEEK that fails will position the record + * pointer to the first key that is higher than the sought + * after key or to LASTREC() + 1 if there is no higher key. + * When disabled, which is the default, a SEEK that fails + * will position the record pointer to LASTREC()+1. + * _SET_TYPEAHEAD + * Sets the size of the keyboard typeahead buffer. Defaults + * to 50. The minimum is 16 and the maximum is 4096. + * _SET_UNIQUE | + * When enabled, indexes are not allowed to have duplicate + * keys. When disabled, indexes are allowed duplicate keys. + * _SET_WRAP | + * When enabled, lightbar menus can be navigated from the + * last position to the first and from the first position + * to the last. When disabled, which is the default, there + * is a hard stop at the first and last positions. + * $RETURNS$ The current or previous setting + * $END$ + */ HARBOUR HB_SET (void) { BOOL bFlag; @@ -289,8 +526,8 @@ HARBOUR HB_SET (void) if (args > 1) hb_set.HB_SET_DATEFORMAT = set_string (pArg2, hb_set.HB_SET_DATEFORMAT); break; case HB_SET_DEBUG : - hb_retl (hb_set.HB_SET_DEBUG); - if (args > 1) hb_set.HB_SET_DEBUG = set_logical (pArg2); + hb_retni (hb_set.HB_SET_DEBUG); + if (args > 1) hb_set.HB_SET_DEBUG = set_number (pArg2, hb_set.HB_SET_DEBUG); break; case HB_SET_DECIMALS : hb_retni (hb_set.HB_SET_DECIMALS); @@ -419,7 +656,13 @@ HARBOUR HB_SET (void) break; case HB_SET_TYPEAHEAD : hb_retni (hb_set.HB_SET_TYPEAHEAD); - if (args > 1) hb_set.HB_SET_TYPEAHEAD = set_logical (pArg2); + if (args > 1) + { + /* Set the value and limit the range */ + hb_set.HB_SET_TYPEAHEAD = set_logical (pArg2); + if( hb_set.HB_SET_TYPEAHEAD < 16 ) hb_set.HB_SET_TYPEAHEAD = 16; + else if( hb_set.HB_SET_TYPEAHEAD > 4096 ) hb_set.HB_SET_TYPEAHEAD = 4096; + } break; case HB_SET_UNIQUE : hb_retl (hb_set.HB_SET_UNIQUE); @@ -449,7 +692,7 @@ void InitializeSets (void) hb_set.HB_SET_CURSOR = SC_NORMAL; hb_set.HB_SET_DATEFORMAT = (char*)hb_xgrab (9); memcpy (hb_set.HB_SET_DATEFORMAT, "mm/dd/yy", 9); - hb_set.HB_SET_DEBUG = FALSE; + hb_set.HB_SET_DEBUG = 0; hb_set.HB_SET_DECIMALS = 2; hb_set.HB_SET_DEFAULT = (char*)hb_xgrab (1); *hb_set.HB_SET_DEFAULT = 0; diff --git a/harbour/tests/working/output.prg b/harbour/tests/working/output.prg index 9b8b70e341..874abbeb28 100644 --- a/harbour/tests/working/output.prg +++ b/harbour/tests/working/output.prg @@ -7,7 +7,8 @@ function Main() OUTSTD (cNewLine, "Testing Harbour device management on", DATE()) SET ALTERNATE TO OUTPUT ADDITIVE - SET PRINTER TO OUTPUT ADDITIVE + SET PRINTER TO OUTPUT + SET MARGIN TO 5 QOUT ("SCREEN, NOT ALTERNATE, NOT PRINTER") @ 5,5 SAY "SCREEN, NOT ALTERNATE NOT PRINTER" SET ALTERNATE ON