參數(shù)資料
型號: NSB8
廠商: Electronic Theatre Controls, Inc.
英文描述: BASIC interpreter for Z80 family
中文描述: Z80的BASIC解釋為家庭
文件頁數(shù): 106/158頁
文件大?。?/td> 752K
代理商: NSB8
grifo
ITALIAN TECHNOLOGY
Page 94
NSB8 Rel. 5.10
SUBROUTINES
When writing programs, you will often find that you need to repeat what amounts to essentially the
same sequence of statements at various separate locations in the program text. For example, your
program may require the user to answer yes or no to certain questions. After writing the program,
you find that sequences similar to that below occur several times in the text:
10 REM Get yes (Y) or no (N) answer in A$.
20 INPUT “PLEASE ANSWER YES OR NO: “,A$
30 IF A$=” “ THEN 20 \ REM No answer given.
40 A$=A$ (1,1)
50 IF A$=”Y” THEN 70 \ REM OK answer
60 IF A$<>”N” THEN 20 \ REM Not = Y or N either.
70 REM At this point, answer was Y or N.
It is certainly troublesome for you (and a waste of program space besides) to type the same sequence
of statements over and over again. If you required several such answers at one point in the program,
of course, you could use a loop to repeat the statements as often as necessary. However, the problem
is different when you must perform the same actions in different parts of the program.
A very nice solution to this problem involves writing just one copy of the segment at one point in the
program, then somehow telling BASIC to rexecute that part whenever necessary. That is, at those
points in the program where you need to get a yes or no answer, BASIC would jump over to the part
of the program which gets the answer, then return to the original point to continue on with whatever
should happen after the answer has been obtained.
In this situation, the answer segment would be called a SUBROUTINE. This subroutine would be
invoked (or called) from other parts of the program to perform its single, important task.
NSB8
makes available two special statements which provide subroutine capability (both are
described in detail in their own sections). The first is GOSUB, which is used to call a subroutine. The
GOSUB keyword is followed by a line number, which tells BASIC where the subroutine begins in
the program text. BASIC reacts to a GOSUB by transferring execution to the specified line number,
while remembering the point where the subroutine was called. The action of the GOTO is similar,
but no calling location is remembered, which makes GOTO unsuitable for subroutine calling. When
the subroutine is finished, BASIC uses the remembered location to return to the point in the program
immediately after the subroutine was called. BASIC knows when a subroutine is finished only when
it executes a RETURN statement. RETURN merely says to BASIC: go back to the calling point
now. It is not necessary to make RETURN the last physical statement in a subroutine, though it turns
out that, in practice, this usually happens.
The answer program segment above may be turned into a legal BASIC subroutine merely by
replacing the last REM statement with RETURN, and translating the appropriate line numbers:
1000 REM Subroutine example.
1010 REM Get yes (Y) or no (N) answer in A$.
1020 INPUT “PLEASE ANSWER YES OR NO: “,A$
1030 IF A$=” “ THEN 1020 \ REM No answer given.
1040 A$=A$(1,1) \ REM Examine 1st char only.
1050 IF A$=”Y” THEN 1070 \ REM OK answer.
1060 IF A$<>”N” THEN 1020 \ REM Not = Yor N either.
1070 RETURN
相關PDF資料
PDF描述
NSB9435T1 High Current Bias Resistor Transistors(高強度電流偏置電阻晶體管)
NSBA114EDXV6T1 Dual Bias Resistor Transistors(雙偏置電阻晶體管)
NSBA114YDXV6T1 Dual Bias Resistor Transistors(雙偏置電阻晶體管)
NSBC143TPDXV6T1 Dual Bias Resistor Transistors(雙偏置電阻晶體管)
NSBC144EPDXV6T1 Dual Bias Resistor Transistors(雙偏置電阻晶體管)
相關代理商/技術參數(shù)
參數(shù)描述
NSB8AT 制造商:VISHAY 制造商全稱:Vishay Siliconix 功能描述:Glass Passivated General Purpose Plastic Rectifier
NSB8AT/31 功能描述:整流器 50 Volt 8.0 Amp 125 Amp IFSM RoHS:否 制造商:Vishay Semiconductors 產品:Standard Recovery Rectifiers 配置: 反向電壓:100 V 正向電壓下降: 恢復時間:1.2 us 正向連續(xù)電流:2 A 最大浪涌電流:35 A 反向電流 IR:5 uA 安裝風格:SMD/SMT 封裝 / 箱體:DO-221AC 封裝:Reel
NSB8AT/45 功能描述:整流器 50 Volt 8.0 Amp 125 Amp IFSM RoHS:否 制造商:Vishay Semiconductors 產品:Standard Recovery Rectifiers 配置: 反向電壓:100 V 正向電壓下降: 恢復時間:1.2 us 正向連續(xù)電流:2 A 最大浪涌電流:35 A 反向電流 IR:5 uA 安裝風格:SMD/SMT 封裝 / 箱體:DO-221AC 封裝:Reel
NSB8AT/81 功能描述:二極管 - 通用,功率,開關 50 Volt 8.0 Amp 125 Amp IFSM RoHS:否 制造商:STMicroelectronics 產品:Switching Diodes 峰值反向電壓:600 V 正向連續(xù)電流:200 A 最大浪涌電流:800 A 配置: 恢復時間:2000 ns 正向電壓下降:1.25 V 最大反向漏泄電流:300 uA 最大功率耗散: 工作溫度范圍: 安裝風格:SMD/SMT 封裝 / 箱體:ISOTOP 封裝:Tube
NSB8AT-E3/31 功能描述:整流器 50 Volt 8.0 Amp 125 Amp IFSM RoHS:否 制造商:Vishay Semiconductors 產品:Standard Recovery Rectifiers 配置: 反向電壓:100 V 正向電壓下降: 恢復時間:1.2 us 正向連續(xù)電流:2 A 最大浪涌電流:35 A 反向電流 IR:5 uA 安裝風格:SMD/SMT 封裝 / 箱體:DO-221AC 封裝:Reel