计算机英语:BASIC语言入门
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
How to Use BASIC
Getting Started in BASIC
The best way to learn the computer language into do, and you will learn much quicker if you dare to make mistakes.Don't worry about breaking the computer by mistyping something. The computer can take care of itself If you have questions about how BASIC will respond to a particular instruction, try it and sec.
Each instruction has a particular format, or syntax. If you do not follow the correct syntax, BASIC will usually display an error message. You can then reenter the instruction correctly。
At first, you need to know both to get into BASIC and ho-, N, to get out. Once you have learned some BASIC, you may begin to type. After you type alien the computer will wait for you to type a signal that you arc finished with the line. You give this signal by tapping the [Enter] key.This key is usually a large one located to the right of the alphabetic keyboard. It is similar in purpose and in placement to the carriage [Enter] key on a typewriter.
As You type, You'll notice a blinking light on the screen that indicates where the next character will appear. This is the cursor. When you press [Enter],the cursor moves to the beginning of the next line.The cursor always lets you know where you are on the screen.
Let's try using BASIC as a calculator. We do this by using the PRINT statement,
PRINT 3
3
We typed PRINT followed by a space, the digit3,and pressed [Enter].BASIC responded by display-in the digit 3.
PRINT 2+2
4
We typed PRINT followed by a space and the numeric expression 2+2.BASIC evaluated the expressions and displayed the result. Here is another example:
PRINT 3,2+2
34
When we tap [Enter],we tell the BASIC Interpreter to check our command for errors and, if none are found, translate the command into machine language and execute. All that happens at great speed! Let’s try a few more examples.
We can make BASIC type two values on online by placing a comma between calculations.
PRINT 1,2,3,4,5
12345
PRINT I,2,3,4,5
12345
Notice what happened:BASIC divided the display line into print zones.These print zones are commonly spaced columns apart, creating five print zone son an 80-column screen.(The exact number will depend on the dialect.)The comma between the values causes BASIC to skip to the next print zone for each value. By using commas,we can print output in neat columns. The extra spaces between values on the PRINT line, as in the second example, do not affect the spacing of the output。
Numeric values are displayed with a minus signing front if the value is negative and a space in front if the value is positive.In most dialects they are also followed by a space.
If you want to print values next to one another, you use the semicolon, which suppresses movement tote next print zone. Here is an example:
PRINT I;-2;3+3
1 -26
Using the semicolon, results are printed next tone another, with the space for the sign in front and a space after.
The comma and the semicolon are used as delimiters to separate values.Because of this,no commas should be placed in values over 999.To print 12,345we must type PRINT 12345。
If we write PRINT12,345,BASIC will interpret it as the two numbers12 and 345。
In our initial discussions we Novell be printing to the screen.however.the same Information can be printed on the printer if our system has one.In most systems this is done with the LPRINT statement MINT uses the same syntax as PRINT.However, PRINT directs output to the printer instead of the screen.On some systems,simultaneously pressing the[Ctrl] and [Parts] keys or the [Ctrl]。
and [P] keys will cause all output that is sent to the screen to be sent to the printer as well.This acts as a toggle.That is, the first [Ctrl] and [Parts] (for example) will turn on the connection between the computer and printer. The next [Citric] and putsch will turn it off. Because dialects vary so widely, we will not describe LPRINT in detail.
翻译:
怎样使⽤BASIC语⾔
BASIC语⾔⼊门
学习计算机语⾔的⽅法就是试着编程,且如果你敢于犯错误的⼀话,将学得更快。
不要担⼼敲错了什么会弄坏计算机。
计算机会照顾好⾃⼰的。
如果你想知道BASIC对⼀条特定的指令反应如何,不妨上机操作试试看。
每条指令都有特别的格式或语法。
如果语法错误,BASIC⼀般将显⽰出错信息。
接着可重新键⼊正确的指令。
⾸先需要知道的是如何进⼊和退出BASIC系统。
⼀旦你学了⼀些BASIC语⾔之后,便可开始键⼊指令。
敲完⼀⾏后,计算机将等待你键⼊指⽰程序⾏结束的信号。
此时,敲回车[Enter]键即可。
该键较⼤,通常位于字母键盘的右边。
它与打字机上的换⾏回车键的功能和位置都相仿。
有⼀闪烁亮点提⽰下⼀个字符出现的位置。
这就是光标。
敲回车键后,光标移到下⼀⾏的开头。
光标总是提⽰你当前在屏幕上所处的位置。
现在,让我们试着把BASIC当计算器使⽤。
这需要⽤到打印语句
PRINT 3
3
我们键⼊“PRINT”,接着是⼀个空格和数字“3”,并按回车键。
BASIC的反应就是显⽰数字3。
PRINT 2+2
4
我们键⼊“PRINT”和空格及数值表达式“2+2”。
BASIC将表达式的值计算出来并显⽰结果。
再举⼀个例⼦:
PRINT 3,2+2
34
当我们敲回车键时,即是通知BASIC解释程序检查指令有⽆错误,如果没有发现错误,就将指令编译成机器语⾔并执⾏。
所有这些⼯作完成的速度极快!让我们再多看⼏个例⼦。
通过在计算式中加逗号的⽅式,我们可以使BASIC在同⼀⾏⾥显⽰两个数值。
PRINT 1,2,3,4,5
12345
PRINT I,2,3,4,5
12345
注意看发⽣了什么变化: BASIC将显⽰⾏划分成了打印区。
这些打印区各⾃空出的列数相同,即将80列的屏幕划分成了5个打印区(具体数字取决于BASIC⽂本)数值间的逗号使得BASIC在显⽰每个数值时都要跳过⼀个打印区。
通过使⽤逗号,我们可打印出整齐的各列来。
在第⼆个例⼦中打印⾏各数值间的多余空格不会影响到最终结果之间的间隔。
如果数字的值为负,则显⽰时其前⾯有⼀负号:若数字的值为正,显⽰时其前会有⼀空格。
在⼤多数BASIC语句中,数值显⽰时其后亦有⼀空格。
如果你想使打印出的数值⼀个接⼀个地排列,可使⽤分号“;” ,它将抑制数值向下⼀个打印区的移动。
现举⼀例如下: PRINT I;-2,3+3
1-26
使⽤分号后,打印出的结果除了其前⾯的符号和后⽽的空格外,将⼀个紧接着⼀个显⽰。
逗号和分号可⽤作分隔数值的⼯具。
因此,数值999中间就不应该有逗号I要打印12,345我们必须键⼊“PRITN12345”。
如果编写成“PRfNT12,345”BASIC将把它编译成两个数值“12”和“345”。
前述的讨论主要是针对屏幕打印的;实际上,如果你的系统配置有⼀台打印机的话,同样的信息也可以通过打印机打印出来〕在⼤多数系统中,这可通过“LPRINT “语句来完成。
LPRINT与PRINT的语法格式是⼀样的。
只不过,LPRINT指⽰输出到打印机上⽽不是屏幕上。
在有些系统中,同时按住!Ctrl]键私 [PrtSc]或[Ctrll键和IN键可使所有输出既显⽰在屏幕上,⼜被送往打c-. 机。
这就象⼀个肘节开关,(例丈第⼀次按)Ctrl]键「」!Prtsc]键)将步I开计算机和打印机间的联系;第⼆次按I Ctril键和[PrtScj键将切断联系由于各BASIC⽂本的差别很⼤,在这⾥我们不打算详细讲述LPRINT.。