For faster navigation, this Iframe is preloading the Wikiwand page for QBasic.

QBasic

此条目没有列出任何参考或来源。 (2023年6月2日)维基百科所有的内容都应该可供查证。请协助补充可靠来源改善这篇条目。无法查证的内容可能会因为异议提出而被移除。
QBasic
编程范型过程式编程
实作者Microsoft
发行时间1991年,​33年前​(1991
当前版本
  • 1.1 (1992;稳定版本)
编辑维基数据链接
操作系统MS-DOS, Windows 95, Windows 98, Windows Me, PC DOS, OS/2, eComStation
许可证操作系统的一部分(各种闭源许可证)
网站www.microsoft.com
启发语言
QuickBASIC, GW-BASIC
影响语言
QB64英语QB64

QBasicBASIC(Beginner's All-purpose Symbolic Instruction Code,初学者通用指令代码)语言的一个变种,由美国微软公司开发,1991年随MS-DOS 5.0推出。它不能被编译成独立的可执行文件,来源代码在集成开发环境(IDE)中先被编译成中间代码,然后中间代码在IDE中被解析后执行。它被设计用来代替GW-BASIC,并被置入在MS-DOS 5.0及其更高版本(包括Windows 95)中。QBasic源自于微软稍早推出的QuickBASIC 4.5,但去掉了后者的编译和连接部分。

微软在较新版本的Windows中不再置入QBasic。不过Windows 98的用户可以在光盘的\TOOLS\OLDMSDOS目录中找到它,在Windows 95的光盘中,它存放在\OTHER\OLDMSDOS目录中。微软网站对它的技术支持只对MS-DOS的授权用户有效。

QBasic拥有一个值得称道的整合式开发环境和一个功能强大的整合调试器,这一切在那个时代让人耳目一新。

语法

和Quick BASIC类似而又不同于微软其他BASIC的早期实现版本的是,QBasic是一种结构化的编程语言。和GW-BASIC相比,QBasic的主要改进是:

  • 扩充了变量和常量的类型
    • 变量名长度:40个字符         
    • 增加了长整型、定长字符型变量         
    • 可定义数值常量、字符串常量         
  • 提供了新的选择结构         
    • 条件语句
        IF  <条件>  THEN
           <语句组1>
        ELSE
           <语句组2>
        END IF
    • 多分支语句SELECT
  • 改进了循环结构
    增加以下两个循环语句:
    • WHILE循环
        WHILE <条件>
         <循环体>
        WEND
    • DO循环
        DO WHILE <条件>
         <循环体>
        LOOP
  • 子程序和函数作为单独的模块
  • 不需要行号,虽然依旧支援行号的使用。

代码示例

Hello, World!程序

print "Hello, World!"

简单的运算

let A=10
let B=20
let C=A+B
Print C

可以进行交互加法的运算

input "a=";a
input "b=";b
let c=a+b
print c

对于其他运算,只要将运算符号改变并添加其他需要的自变量即可

绘制一个图形

绘制出一条斜线

screen 1
line (10,10)-(20,20)

其中的数字可以更改。同样也可以使用这个语句来绘制矩形或者点 绘制一个空心圆形

screen 1
CIRCLE (10,10),10

其中,在括号内的数字代表圆心的位置,逗号后的数字是圆形半径

快捷键

Ctrl+Break:中断正在运行的程序;
F5:继续运行被中断的程序;
⇧ Shift+F5:从第一条语句开始重新运行程序;
F4:当程序中断运行时,查看运行结果屏幕,再按一次F4则切换回代码屏幕;
F1:获得帮助。

外部链接

{{bottomLinkPreText}} {{bottomLinkText}}
QBasic
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?