www.pudn.com > 模仿basic函数的某些c语言函数.rar > BASIC.H
/************************************************************************ * This file contains the headers, prototypes and define statements for * * QuickBasic 4.5 and otherwise. Written by David Wesson * ************************************************************************/ #include#include #include #include #include #include #include #include #include #include #include #include #include #include #define DEFAULT 0 #define A 1 #define B 2 #define C 3 #define D 4 #define E 5 #define F 6 #define G 7 #define VIDEO 0x10 #define SCROLLUP 0x6 #define SETPOS 0x2 #define DOS 0x21 #define LPRINTER 0x17 #define BLINK 16 #define ON 1 #define OFF 0 #define YES 1 #define NO 0 #define TRUE 1 #define FALSE 0 #define EXIST 0 #define WRITE 2 #define READ 4 #define READWRITE 6 #define READ_TEXT "rt" #define READ_BINARY "rb" #define WRITE_TEXT "wt" #define WRITE_BINARY "wb" #define MAX_PRN_LINE 133 #define MAX_SCREEN_LINE 81 #define MAX_PATH_SIZE 66 #define BLOCK 0x0007 #define HALFBLOCK 0x0407 #define LINE2 0x0607 #define LINE1 0x0707 #define NO_CURSOR 0x2000 #define FF 12 #define LF 10 #define ESC 27 #define ENTER '\r' #define NEWLINE '\n' #define BLANK ' ' #define TAB '\t' #define BEEP putchar( '\a') #define TIMER time( <ime ) #define TIME _strtime( timebuf ) #define DATE _strdate( datebuf ) #define SPACE( x ) string( x, 32 ) #define ASC( x ) itoa( (int) x, ascii, 10 ) #define LPRINT( x ) fputs( x, stdprn ) #define VIEW_PRINT( w, x, y, z ) \ w1 = w; \ w2 = x; \ w3 = y; \ w4 = z; \ _settextwindow( w1, w2, w3, w4 ) #define CURSOR_ON _settextcursor( LINE2 ) #define CURSOR_OFF _settextcursor( NO_CURSOR ) #define LOCATE( x, y ) _settextposition( (short) x, (short) y ) #define GET_CURS_POS cursor = _gettextposition() #define CLEAR_WINDOW _clearscreen( _GWINDOW ) #define WRAP_ON _wrapon( _GWRAPON ) #define WRAP_OFF _wrapon( _GWRAPOFF ) #define CLS _clearscreen( _GCLEARSCREEN ); \ LOCATE( 1, 1 ) #define SAVE_SCREEN oldfore = (int) _gettextcolor(); \ oldback = (int) _getbkcolor(); \ oldpos = _gettextposition(); \ oldcurs = _gettextcursor(); #define RESTORE_SCREEN _settextcolor( (short) oldfore ); \ _setbkcolor( (long) oldback ); \ _clearscreen( _GCLEARSCREEN ); \ _settextposition( oldpos.row, oldpos.col ); \ _settextcursor( oldcurs ); \ CURSOR_ON; #define COLOR( x, y ) _settextcolor( (short) x ); \ _setbkcolor( (long) y ); #define FILE_ERROR RESTORE_SCREEN; \ puts( "Error opening file. Check filename." ); \ exit( 1 ) #define SWAPD( x, y ) { double temp; \ (temp) = (x); \ (x) = (y); \ (y) = (temp); } #define SWAPS( x, y, z ) { char temp[z]; \ memmove( temp, x, z ); \ memmove( x, y, z ); \ memmove( y, temp, z ); } #define ARRAY_ELEMS( x ) (sizeof( x ) / sizeof x[0] ) #define SET_BIT( x, y ) (( x ) |= (1 << ( y ))) #define UNSET_BIT( x, y ) (( x ) &= ~(1 << ( y ))) #define TEST_BIT( x, y ) (( x ) & (1 << ( y ))) long freespace( int drive ); void print( int row, int col, long fore, long back, char *buffer ); void scrollup( void ); char *tabout( char *source, int space, int maxsize); char *rtrim( char *string ); char *ltrim( char *string ); char *timestamp( void ); char *filestamp( char *filename ); char *string( size_t num, int ascii ); char *justfilename( char *pathname ); char *lftstr( char *string, int len ); char *rtstr( char *string, int len ); char *midstr( char *string, int offset, int len ); int checkkey( void ); int printer( void ); int int86(int intno, union REGS *inregs, union REGS *outregs); long lof( char *filename ); #if defined( MAIN ) int w1 = 1, w2 = 1, w3 = 25, w4 = 80, prow = 0; long back = 0, high = 15, fore = 7; long oldfore = 7, oldback = 0; short far oldcurs; struct rccoord oldpos, cursor; char timebuf[9], datebuf[9]; union REGS inregs, outregs; FILE *infile, *outfile; time_t ltime; struct stat filestat; #else extern int w1, w2, w3, w4, prow; extern long high, fore, oldfore, back, oldback; extern short far oldcurs; extern struct rccoord oldpos, cursor; extern char timebuf[], datebuf[]; extern union REGS inregs, outregs; extern FILE *infile, *outfile; extern time_t ltime; extern struct stat filestat; #endif