Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Line number
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==History== ===FORTRAN=== In [[Fortran]], as first specified in 1956, line numbers were used to define input/output patterns, to specify statements to be repeated, and for conditional branching. For example:<ref>{{cite book|last1=Programming Research Department, International Business Machines Corporation|title=The FORTRAN Automatic Coding System for the IBM 704 EDPM: Preliminary Operator's Manual|date=April 8, 1957|pages=6β37|url=http://www.softwarepreservation.org/projects/FORTRAN/manual/Prelim_Oper_Man-1957_04_07.pdf}}</ref> <syntaxhighlight lang="fortran"> DIMENSION ALPHA(25), RHO(25) 1) FORMAT(5F12.4) 2) READ 1, ALPHA, RHO, ARG SUM = 0.0 DO 3 I=1, 25 IF (ARG-ALPHA(I)) 4,3,3 3) SUM = SUM + ALPHA(I) 4) VALUE = 3.14159*RHO(I-1) PRINT 1, ARG, SUM, VALUE GO TO 2 </syntaxhighlight> Like [[assembler language]] before it, Fortran did not assume every line needed a label (line number, in this case). Only statements referenced elsewhere required a line number: * Line 1 specifies a format pattern for input; the {{code|READ}} command in line 2 and the later {{code|PRINT}} command both reference this line. * The {{code|DO}} loop executes line 3. * The [[arithmetic IF]] statement branches to line 4 on a negative value, line 3 on zero, and again line 3 on a positive value. While the line numbers are sequential in this example, in the very first "complete but simple [Fortran] program" published the line numbers are in the sequence 1, 5, 30, 10, 20, 2.<ref name="Sayre_1956">{{cite book |title=The FORTRAN Automatic Coding System for the IBM 704 EDPM: Programmer's Reference Manual |publisher=Applied Science Division and Programming Research Department, [[International Business Machines Corporation]] |location=New York, USA |date=1956-10-15 |editor-first=David |editor-last=Sayre |editor-link=David Sayre |author-first1=John Warner |author-last1=Backus |author-link1=John Warner Backus |author-first2=R. J. |author-last2=Beeber |author-first3=Sheldon F. |author-last3=Best |author-first4=Richard |author-last4=Goldberg |author-link4=Richard Goldberg |author-first5=Harlan L. |author-last5=Herrick |author-first6=R. A. |author-last6=Hughes |author-first7=L. B. |author-last7=Mitchell |author-first8=Robert A. |author-last8=Nelson |author-first9=Roy |author-last9=Nutt |author-link9=Roy Nutt |author-first10=David |author-last10=Sayre |author-link10=David Sayre |author-first11=Peter B. |author-last11=Sheridan |author-first12=Harold |author-last12=Stern |author-first13=Irving |author-last13=Ziller |page=46 |url=http://archive.computerhistory.org/resources/text/Fortran/102649787.05.01.acc.pdf |access-date=2022-07-04 |url-status=live |archive-url=https://web.archive.org/web/20220704193549/http://archive.computerhistory.org/resources/text/Fortran/102649787.05.01.acc.pdf |archive-date=2022-07-04}} (2+51+1 pages)</ref> Line numbers could also be assigned to fixed-point variables (e.g., {{code|ASSIGN}} ''i'' {{code|TO}} ''n'') for referencing in subsequent assigned GO TO statements (e.g., {{code|GO TO}} ''n,(n1,n2,...nm)''). ===COBOL=== In [[COBOL]], line numbers were specified in the first six characters (the ''sequence number area'') of [[punched card]]s. This was originally used for facilitating mechanical card sorting to assure intended program code sequence after manual handling. The line numbers were actually ignored by the compiler. ===DOPE=== In 1962, [[DOPE (Dartmouth Oversimplified Programming Experiment)]] became one of the first programming languages to require a line number for every statement and to use sequential ordering of line numbers. Line numbers were specified as destinations for two commands, C (Compare operation, an arithmetic IF) and T (To operation, a GO TO). ===JOSS=== In 1963, [[JOSS]] independently made line numbers mandatory for every statement in a program and ordered lines in sequential order. JOSS introduced the idea of a single [[command line]] editor that worked both as an interactive language and a program editor. Commands that were typed without a line number were executed immediately, in what JOSS referred to as "direct mode". If the same line was prefixed with a line number, it was instead copied into the program code storage area, which JOSS called "indirect mode". Unlike FORTRAN before it or BASIC after it, JOSS required line numbers to be fixed-point numbers consisting of a pair of two-digit integers separated by a period (e.g., 1.1). The portion of the line number to the left of the period is known as the "page" or "part", while the portion to the right is known as the "line"; for example, the line number {{code|10.12}} refers to page 10, line 12. Branches can target either a page or a line within a page. When the later format is used, the combined page and line is known as a "step". Pages are used to define [[subroutine]]s, which return when the next line is on a different page. For instance, if a subroutine for calculating the square root of a number is in page 3, one might have three lines of code 3.1, 3.2 and 3.3, and it would be called using {{code|Do part 3.}} The code would return to the statement after the Do when it reaches the next line on a different page, for instance, 4.1. There is no need for the equivalent of a {{code|RETURN}} at the end, although if an early return is required, {{code|Done}} accomplishes this. Example: *Routine to ask the user for a positive value and repeat until it gets one 01.10 Demand X as "Enter a positive value greater than zero". 01.20 Done if X>0. 01.30 To step 1.1 === BASIC === Introduced in 1964, [[Dartmouth BASIC]] adopted mandatory line numbers, as in JOSS, but made them integers, as in FORTRAN. As defined initially, BASIC only used line numbers for {{code|GOTO}} and {{code|GOSUB}} (go to subroutine, then return). Some [[Tiny BASIC]] implementations supported numeric expressions instead of constants, while [[switch statement]]s were present in different dialects ({{code|ON}} {{code|GOTO}}; {{code|ON}} {{code|GOSUB}}; {{code|ON ERROR GOTO}}). Line numbers were rarely used elsewhere. One exception was allowing the pointer used by {{code|READ}} (which iterated through {{code|DATA}} statements) to be set to a specific line number using {{code|RESTORE}}. <syntaxhighlight lang="bbcbasic"> 1 REM RESTORE COULD BE USED IF A BASIC LACKED STRING ARRAYS 2 DIM M$(9): REM DEFINE LENGTH OF 9 CHARACTERS 5 INPUT "MONTH #?"; M: IF M<1 OR M>12 THEN 5 7 RESTORE 10*M: READ M$: PRINT M$ 10 DATA "JANUARY" 20 DATA "FEBRUARY" 30 DATA "MARCH" ... </syntaxhighlight> In the first editions of Dartmouth BASIC, {{code|THEN}} could only be followed by a line number (for an ''implied GOTO''), not - as in later implementations - by a statement. The range of valid line numbers varied widely from implementation to implementation, depending on the representation used to store the binary equivalent of the line number (one or two bytes; signed or unsigned). While Dartmouth BASIC supported 1 to 99999, the typical microcomputer implementation supported 1 to 32767 (a signed 16-bit word). {| class="wikitable" |+ Valid Line Numbers in [[Tiny BASIC#Dialects compared|Early BASIC Implementations]] |- ! Range !! Dialect |- | 1 to 254 || MINOL |- | 1 to 255 || Tiny BASIC Design Note |- | 2 to 255 || Denver Tiny BASIC |- | 0 to 999 || UIUC BASIC |- | 1 to 2045 || [[BASIC-PLUS|DEC BASIC-8]] |- | 0 to 32767 || LLL BASIC, NIBL |- | 1 to 32767 || [[Integer BASIC|Apple I BASIC]], [[Level I BASIC]], [[Palo Alto Tiny BASIC]] |- | 0 to 65529 || [[GW-BASIC]], [[IBM BASIC]] |- | 1 to 65535 || [[Altair BASIC|Altair 4K BASIC]], MICRO BASIC 1.3, 6800 Tiny BASIC, Tiny BASIC Extended |- | 1 to 99999 || [[Dartmouth BASIC]] |- | 1 to 999999 || [[SCELBAL]] |- | 0 to 1*10^40-1 || [[QBASIC]] 1) |} 1) While QBASIC does make use of structured programming and thus doesn't need line numbers, it is still possible to run code with line numbers in QBASIC.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)