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

📄 bwx_iqc.c

📁 这是一个简易的basic语言解释器, 可供我们学习和改进.
💻 C
📖 第 1 页 / 共 2 页
字号:
   union REGS ibm_registers;   /* call the BDOS function 0x10 to read the current cursor position */   ibm_registers.h.ah = 3;   ibm_registers.h.bh = (unsigned char) _getvisualpage();   int86( 0x10, &ibm_registers, &ibm_registers );   /* set text to this position */   _settextposition( ibm_registers.h.dh, ibm_registers.h.dl );   /* and move down one position */   prn_xprintf( stdout, "\n" );   return TRUE;   }#if COMMON_CMDS/***************************************************************        FUNCTION:       bwb_edit()        DESCRIPTION:***************************************************************/struct bwb_line *bwb_edit( struct bwb_line *l )   {   char tbuf[ MAXSTRINGSIZE + 1 ];   char edname[ MAXSTRINGSIZE + 1 ];   struct bwb_variable *ed;   FILE *loadfile;   ed = var_find( DEFVNAME_EDITOR );   str_btoc( edname, var_getsval( ed ));   sprintf( tbuf, "%s %s", edname, CURTASK progfile );#if INTENSIVE_DEBUG   sprintf( bwb_ebuf, "in bwb_edit(): command line <%s>", tbuf );   bwb_debug( bwb_ebuf );#else   system( tbuf );#endif   /* open edited file for read */   if ( ( loadfile = fopen( CURTASK progfile, "r" )) == NULL )      {      sprintf( bwb_ebuf, err_openfile, CURTASK progfile );      bwb_error( bwb_ebuf );      iqc_setpos();      return bwb_zline( l );      }   /* clear current contents */   bwb_new( l ); /* Relocated by JBV (bug found by DD) */   /* and (re)load the file into memory */   bwb_fload( loadfile );   iqc_setpos();   return bwb_zline( l );   }/***************************************************************        FUNCTION:       bwb_renum()	DESCRIPTION:    This function implements the BASIC RENUM			command by shelling out to a default			renumbering program called "renum".			Added by JBV 10/95	SYNTAX:		RENUM***************************************************************/#if ANSI_Cstruct bwb_line *bwb_renum( struct bwb_line *l )#elsestruct bwb_line *bwb_renum( l )   struct bwb_line *l;#endif   {   char tbuf[ MAXSTRINGSIZE + 1 ];   FILE *loadfile;   sprintf( tbuf, "renum %s\0", CURTASK progfile );#if INTENSIVE_DEBUG   sprintf( bwb_ebuf, "in bwb_renum(): command line <%s>", tbuf );   bwb_debug( bwb_ebuf );#else   system( tbuf );#endif   /* open edited file for read */   if ( ( loadfile = fopen( CURTASK progfile, "r" )) == NULL )      {      sprintf( bwb_ebuf, err_openfile, CURTASK progfile );      bwb_error( bwb_ebuf );      iqc_setpos();      return bwb_zline( l );      }   /* clear current contents */   bwb_new( l ); /* Relocated by JBV (bug found by DD) */   /* and (re)load the file into memory */   bwb_fload( loadfile );   iqc_setpos();   return bwb_zline( l );   }/***************************************************************        FUNCTION:       bwb_files()        DESCRIPTION:***************************************************************/struct bwb_line *bwb_files( struct bwb_line *l )   {   char tbuf[ MAXVARNAMESIZE + 1 ];   char finame[ MAXVARNAMESIZE + 1 ];   char argument[ MAXVARNAMESIZE + 1 ];   struct bwb_variable *fi;   struct exp_ese *e;   fi = var_find( DEFVNAME_FILES );   str_btoc( finame, var_getsval( fi ));   /* get argument */   adv_ws( l->buffer, &( l->position ));   switch( l->buffer[ l->position ] )      {      case '\0':      case '\r':      case '\n':         argument[ 0 ] = '\0';         break;      default:         e = bwb_exp( l->buffer, FALSE, &( l->position ) );         if ( e->type != STRING )            {            bwb_error( err_mismatch );            return bwb_zline( l );            }         str_btoc( argument, exp_getsval( e ) );         break;      }   sprintf( tbuf, "%s %s", finame, argument );#if INTENSIVE_DEBUG   sprintf( bwb_ebuf, "in bwb_files(): command line <%s>", tbuf );   bwb_debug( bwb_ebuf );#else   system( tbuf );#endif   iqc_setpos();   return bwb_zline( l );   }#endif					/* COMMON_CMDS */#if INTERACTIVE/***************************************************************        FUNCTION:       fnc_inkey()        DESCRIPTION:    This C function implements the BASIC INKEY$        		function.  It is implementation-specific.***************************************************************/extern struct bwb_variable *fnc_inkey( int argc, struct bwb_variable *argv )   {   static struct bwb_variable nvar;   char tbuf[ MAXSTRINGSIZE + 1 ];   static int init = FALSE;   /* initialize the variable if necessary */   if ( init == FALSE )      {      init = TRUE;      var_make( &nvar, STRING, "fnc_inkey" );      }   /* check arguments */#if PROG_ERRORS   if ( argc > 0 )      {      sprintf( bwb_ebuf, "Two many arguments to function INKEY$()" );      bwb_error( bwb_ebuf );      return &nvar;      }#else   if ( fnc_checkargs( argc, argv, 0, 0 ) == FALSE )      {      return NULL;      }#endif   /* body of the INKEY$ function */   if ( _bios_keybrd( _KEYBRD_READY ) == 0 )      {      tbuf[ 0 ] = '\0';      }   else      {      tbuf[ 0 ] = (char) _bios_keybrd( _KEYBRD_READ );      tbuf[ 1 ] = '\0';      }   /* assign value to nvar variable */   str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );   /* return value contained in nvar */   return &nvar;   }#endif				/* INTERACTIVE */#if MS_CMDS/***************************************************************        FUNCTION:       bwb_cls()        DESCRIPTION:    This C function implements the BASIC CLS        		command.  It is implementation-specific.***************************************************************/extern struct bwb_line *bwb_cls( struct bwb_line *l )   {   _clearscreen( _GCLEARSCREEN );   return bwb_zline( l );   }/***************************************************************        FUNCTION:       bwb_locate()        DESCRIPTION:    This C function implements the BASIC LOCATE        		command.  It is implementation-specific.***************************************************************/extern struct bwb_line *bwb_locate( struct bwb_line *l )   {   struct exp_ese *e;   int row, column;   /* get first argument */   e = bwb_exp( l->buffer, FALSE, &( l->position ));   row = (int) exp_getnval( e );   /* advance past comma */   adv_ws( l->buffer, &( l->position ));   if ( l->buffer[ l->position ] != ',' )      {      bwb_error( err_syntax );      return bwb_zline( l );      }   ++( l->position );   /* get second argument */   e = bwb_exp( l->buffer, FALSE, &( l->position ));   column = (int) exp_getnval( e );   /* position the cursor */   _settextposition( row, column );   return bwb_zline( l );   }/***************************************************************	FUNCTION:       bwb_color()	DESCRIPTION:    This C function implements the BASIC COLOR			command.  It is implementation-specific.***************************************************************/extern struct bwb_line *bwb_color( struct bwb_line *l )   {   struct exp_ese *e;   int color;   /* get first argument */   e = bwb_exp( l->buffer, FALSE, &( l->position ));   color = (int) exp_getnval( e );#if INTENSIVE_DEBUG   sprintf( bwb_ebuf, "Setting text color to %d", color );   bwb_debug( bwb_ebuf );#endif   _settextcolor( (short) color );#if INTENSIVE_DEBUG   sprintf( bwb_ebuf, "Set text color to %d", color );   bwb_debug( bwb_ebuf );#endif   /* advance past comma */   adv_ws( l->buffer, &( l->position ));   if ( l->buffer[ l->position ] == ',' )      {      ++( l->position );      /* get second argument */      e = bwb_exp( l->buffer, FALSE, &( l->position ));      color = (int) exp_getnval( e );#if INTENSIVE_DEBUG      sprintf( bwb_ebuf, "Setting background color to %d", color );      bwb_debug( bwb_ebuf );#endif      /* set the background color */      _setbkcolor( (long) color );#if INTENSIVE_DEBUG      sprintf( bwb_ebuf, "Setting background color to %d\n", color );      bwb_debug( bwb_ebuf );#endif      }   return bwb_zline( l );   }#endif				/* MS_CMDS */

⌨️ 快捷键说明

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