Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
BASIC09
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
==Syntax== ===Program organization=== A key difference between BASIC09 and conventional BASICs of the era, like the canonical [[Microsoft BASIC]], is the addition of the <code>PROCEDURE</code> structure which created separately executable blocks of code. Code in a <code>PROCEDURE</code> had more in common with complete programs in other BASICs, including the variables being [[local variable|local]] to the code, and their ability to be executed in a stand-alone fashion. <code>PROCEDURE</code>s were called by name using the <code>RUN</code> command, and could include variables for function-call semantics; for instance, <code>RUN add(4,7)</code> calls a procedure named <code>add</code> that takes two parameters. Parameters were imported into the procedure using the <code>PARAM</code> keyword, in this example <code>PARAM a,b</code>:{{sfn|Manual|1984|p=5.1}} PROCEDURE add PARAM a,b PRINT a+b A side-effect of the use of named procedures is that the resulting memory workspace is, in effect, its own namespace. In this respect, the BASIC09 system appears to the user to be a directory of callable programs. This contrasts with typical BASICs, where only one program is available at a given time and the construction of larger programs calling library-like code generally requires the [[source code]] to be copied and pasted between separate programs. In BASIC09, the user can <code>LOAD</code> procedures by name into the workspace and then call them from their own code to construct larger programs from the separately stored procedures.{{sfn|Manual|1984|p=3.5}}{{efn|The [[GRASS (programming language)|GRASS]] system was similar in that its BASIC-like language could be assembled from separate named procedures, but did so by leaving everything as untokenized source code, as opposed to pre-compiling as in BASIC09.}} In addition to code in the workspace, if the program invokes <code>RUN</code> with a procedure name that could not be found, it would then look for a disk file with the same name and load and run that file. This worked not only with BASIC09 code, but also any other executable program, including [[machine language]] files. This meant that BASIC09 could easily call system routines.{{sfn|Manual|1984|p=9.12}} In addition to <code>RUN</code>, other common BASIC commands likewise used names. For instance, <code>LIST bob</code> would print out the source code ("list") the procedure named "bob", while <code>LIST*</code> prints out all of the procedures currently in memory. The prettyprinted output from <code>LIST</code> could be redirected to a file or a printer with a shell-like notation, e.g. <code>LIST bob >/p</code>. One could also <code>SAVE</code> and <code>LOAD</code> procedures from storage.{{sfn|Manual|1984|p=2.9}} ===Structured programming=== In addition to the organizational properties of the <code>PROCEDURE</code>, BASIC09 also included a number of extensions to the [[flow control (data)|flow control]] statements found in BASIC to provide more structure. For instance, the <code>IF</code> statement could be used in the traditional <code>IF</code>...<code>THEN</code> format on a single line, or it could be used in a structured multi-line format:{{sfn|Manual|1984|p=9.4}} IF x>10 THEN PRINT "x is larger than 10" ELSE PRINT "x is smaller than 10" ENDIF <code>FOR/NEXT</code> loops naturally have a structured format as the <code>NEXT</code> can be placed on any line, but BASIC09 also added <code>WHILE/ENDWHILE</code> and <code>REPEAT/UNTIL</code> for additional clarity when working with non-indexed loops.{{sfn|Manual|1984|p=9.6-9.7}} It also included the center-exit <code>LOOP/ENDLOOP</code> which used the <code>EXITIF</code> statement for testing anywhere in the loop's body.{{sfn|Manual|1984|p=9.8}} ===Data types=== BASIC09 included several built-in data types. In addition to the traditional string (STRING) and 40-bit floating point (REAL) types found in most BASICs of the era, it also included the 16-bit signed INTEGER, the 8-bit unsigned BYTE, and the logical BOOLEAN type. The BOOLEAN types were not [[Data structure alignment|packed]] into bytes, a single BOOLEAN used an entire 8-bit byte to store a single value. The language provided separate bytewise [[boolean function|boolean operators]] for bitwise operations on BYTEs and INTEGERs.{{sfn|Manual|1984|pp=7.2-7.6}} In contrast to other BASICs that also operated different base types, BASIC09 did not "decorate" the variable name to indicate the type, and instead used the <code>DIM</code> for definitions; for instance, <code>DIM a,b:BOOLEAN</code> to declare two BOOLEAN variables, or <code>DIM c(5):INTEGER</code> for an array of five INTEGERs.{{sfn|Manual|1984|p=7.6}} Additionally, BASIC09 included the <code>TYPE</code> keyword, which allowed compound types to be defined, with each "element" listed on a single line separated by semicolons. For instance:{{sfn|Manual|1984|p=7.8}} TYPE employee_record=name:STRING;number(2):INTEGER;former:BOOLEAN defines an employee record type named <code>employee_record</code> with three elements, <code>name</code>, <code>number</code> and <code>former</code>. The employee_record type can now be used in a definition like any other type, for instance, <code>DIM employees(100):employee_record</code>, which defines an array of 100 employee_record's. The elements are accessed in code using dot notation, for instance, <code>employees(50).name="Bob"</code>.{{sfn|Manual|1984|p=7.8}}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
BASIC09
(section)
Add topic