⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic.h

📁 模仿 BASIC 函数的某些 C 语言函数
💻 H
字号:
/************************************************************************
* This file contains the headers, prototypes and define statements for  *
* QuickBasic 4.5 and otherwise. Written by David Wesson                 *
************************************************************************/

#include <dos.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <direct.h>
#include <string.h>
#include <sys\timeb.h>
#include <time.h>
#include <io.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include <stdio.h>
#include <graph.h>

#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( &ltime )
#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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -