Jump to content

Vilnius BASIC: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
working, still more to come
m Added links.
 
(25 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Short description|Dialect of the BASIC programming language}}
{{infobox programming language
{{infobox programming language
|name = Vilnius Basic
|name = Vilnius Basic
Line 19: Line 20:
[[Image:Basic-Vilnus.png|thumb|256px|Vilnius BASIC on BK-0010-01]]
[[Image:Basic-Vilnus.png|thumb|256px|Vilnius BASIC on BK-0010-01]]


'''Vilnius BASIC''', sometimes known as '''BK BASIC''', is a dialect of the [[BASIC]] [[programming language]] running on the [[Elektronika]] [[Elektronika BK-0010|BK-0010-01/BK-0011M]] and [[UKNC]] computers.<ref>{{ cite book |author1=Митрюхин, В. К. |author2=Донской, А. Н. |author3=Михайлов, А. В. |author4=Немов, А. М. | title = Программирование на БК-0010-01 | url = http://bk0010.narod.ru/docs/bk-prog.html |trans-title=Programming for BK-0010-01 | language = Russian | year = 1986 | id = version 07.24 }}</ref><ref>{{ cite web | url = http://www.homecomputer.de/pages/easteurope_ussr.html | publisher = HCM - The HomeComputer Museum | location = Germany | title = East-European Home-Computer }}</ref> It was developed at [[Vilnius University]], located in [[Lithuania]] which was a republic of the [[Soviet Union]] at the time.
'''Vilnius BASIC''', sometimes known as '''BK BASIC''', is a dialect of the [[BASIC]] [[programming language]] running on the [[Elektronika]] [[Elektronika BK-0010|BK-0010-01/BK-0011M]] and [[UKNC]] computers. It was developed at [[Vilnius University]], located in [[Lithuania]] which was a republic of the [[Soviet Union]] at the time.


In contrast to most [[microcomputer]] dialects of BASIC of the era, which were [[BASIC interpreter|interpreters]], Vilnius BASIC was a [[compile and go]] language that compiled the source when the user entered the <code>RUN</code> command. It was otherwise similar to [[GW-BASIC]] and [[MSX BASIC]] in style and most features, although it lacked some of the multimedia commands found in MSX. One oddity was that it did not allow more than one statement on a single line, a feature normally implemented using the colon. It also lacked the ability to open more than one data file at a time.
In contrast to most [[microcomputer]] dialects of BASIC of the era, which were [[BASIC interpreter|interpreters]], Vilnius BASIC was a [[compile and go]] language that compiled the source when the user entered the <code>RUN</code> command. It was otherwise similar to [[GW-BASIC]] and [[MSX BASIC]] in style and most features, although it lacked some of the multimedia commands found in MSX. One oddity was that it did not allow more than one statement on a single line, a feature normally implemented using the colon. It also lacked the ability to open more than one data file at a time.


Only the [[UKNC]] version had a [[full-screen editor]], versions of the 0010 series machines used a [[line editor]]. Machine-dependent features, like graphics operators, parameters, and <code>PEEK/POKE</code> addresses were also different among the machines.
Only the UKNC version had a [[full screen editor|full-screen editor]], versions of the 0010 series machines used a [[line editor]]. [[Machine-dependent software|Machine-dependent]] features, like graphics operators, parameters, and <code>[[PEEK and POKE|PEEK/POKE]]</code> addresses were also different among the machines.


==Description==
==Description==
Line 29: Line 30:
In contrast to most BASIC dialects of the era, Vilnius BASIC was a [[compile and go]] system, not an [[BASIC interpreter|interpreter]]. When the user types {{code|RUN}}, the compiler reads the code and produces a [[threaded code]] executable that it then ran. Nevertheless, this detail was largely invisible to the user, as the system still allowed statements to be typed in without a line number for [[Direct mode |direct (immediate) mode]], or with a number for indirect mode in which case the new line was added to the program or replaced the same-numbered line if it already existed.
In contrast to most BASIC dialects of the era, Vilnius BASIC was a [[compile and go]] system, not an [[BASIC interpreter|interpreter]]. When the user types {{code|RUN}}, the compiler reads the code and produces a [[threaded code]] executable that it then ran. Nevertheless, this detail was largely invisible to the user, as the system still allowed statements to be typed in without a line number for [[Direct mode |direct (immediate) mode]], or with a number for indirect mode in which case the new line was added to the program or replaced the same-numbered line if it already existed.


By the late 1970s, most microcomputer dialects offered a [[full-screen editor]], in which the user can use the [[cursor keys]] to move around the program and type changes into any visible line of code. The Electronica systems were emulating an [[PDP-11]], machines that had been built in the era before cursor-addressable [[computer terminal]]s were widely available and thus retain the older [[line editor]] style. In these systems, a prompt is displayed that allows the user to type in one line of code, or recall a previously typed line and then edit it in-place.
By the late 1970s, most microcomputer dialects offered a full-screen editor, in which the user can use the [[cursor keys]] to move around the program and type changes into any visible line of code. The Electronica systems were emulating an [[PDP-11]], machines that had been built in the era before cursor-addressable [[computer terminal]]s were widely available and thus retain the older [[line editor]] style. In these systems, a prompt is displayed that allows the user to type in one line of code, or recall a previously typed line and then edit it in-place.


===Statements===
===Commands and statements===
The list of keywords supported in Vilnius can be separated into two groups, those that can only be used in direct mode, and those that can be direct or indirect.
Vilnius' primitives were similar to other BASICs of the era, and supported most of the elementary statements like {{mono|DATA, DEF FN, DIM, END, [[For loop|FOR..TO..STEP..NEXT]], [[GOSUB]], [[GOTO]], [[Conditional (programming)|IF..THEN]] with an optional ELSE, INPUT, (optional) LET, LIST, PRINT, ON...GOTO and ON...GOSUB, READ, [[Comment (computer programming)|REM]], RESTORE, [[Return statement|RETURN]], RUN, STOP}}. In contrast to most dialects, Vilnius did not allow more than one statement per line.


The former, known as commands, included the common {{code|CONT, LIST, NEW, RUN}}. {{code|CLOAD and CSAVE}} load and save programs to [[cassette tape]]. {{code|AUTO}} turned on automatic line number entry, {{code|RENUM}} renumbered the lines in the current program, and {{code|DELETE}} deleted ranges of lines using the same "to" format as LIST, for instance, {{code|DELETE -200}} would delete everything from the start of the program up to an including line 200.
===Math, operators and functions===
As with most dialects, variable names had to start with a letter and could be followed by more letters or digits. Variable names could be any length, but only the first two characters were stored or matched, meaning that typing {{mono|PRT001=1}} followed {{mono|PR=5}} would result in a single variable in memory known as PR with the value 5.


Vilnius' primitives were similar to other BASICs of the era, and supported most of the elementary statements like {{mono|DATA, DEF FN, DIM, END, [[For loop|FOR..TO..STEP..NEXT]], [[GOSUB]], [[GOTO]], [[Conditional (programming)|IF..THEN]] with an optional ELSE, INPUT, (optional) LET, LIST, PRINT, ON...GOTO and ON...GOSUB, READ, [[Comment (computer programming)|REM]], RESTORE, [[Return statement|RETURN]], STOP}}. In contrast to most dialects, Vilnius did not allow more than one statement per line.
Vilnius BASIC had four basic data types, strings, single and double-precision [[floating point]] numbers, and integers. Unless otherwise denoted, variables were assumed to be double-precision, stored in eight bytes and providing about 17 digits of precision. If the {{mono|!}} was added to the variable name, it was stored in single-precision, using four bytes with about 7 digits of precision. As in other dialects, {{mono|$}} indicated it was a string, and {{mono|%}} an integer, using a single 16-bit word. Numeric constants could also be defined as a particular type using the same markers, {{mono|50%}} would store the constant as an integer, while {{mono|0.05!}} or {{mono|5E-02}} stores a single-precision value 0.05, while {{mono|0.05}} or {{mono|5D-02}} stores the same value in the default double-precision. If a value with more precision was assigned to a variable with less, any excess was simply discarded; {{code|A%=1.5}} will result in A% having the value 1.


===Numeric variables, operators and functions===
Vilnius also had the useful ability to type in numeric constants as strings of binary, octal or hexadecimal, by prefixing the string with {{mono|&}} and a single letter indicating the type, {{mono|b, o, h}}. For instance, {{code|A=&H9A8B}} would convert the hexadecimal value to the equivalent decimal value, 39563, and store that in A.
As with most dialects, variable names had to start with a letter and could be followed by more letters or digits. Variable names could be any length, but only the first two characters were stored or matched, meaning that typing {{code|PRT001{{=}}1}} followed {{code|PR{{=}}5}} would result in a single variable in memory known as PR with the value 5.


Vilnius BASIC had four basic data types, strings, single and double-precision [[floating point]] numbers, and integers. Unless otherwise denoted, variables were assumed to be double-precision, stored in eight bytes and providing about 17 digits of precision. For comparison, most MS dialects used a [[Microsoft Binary Format|5-byte format]] for floating point. If {{code|!}} was suffixed to the variable name, the value was stored in single-precision using four bytes with about 7 digits of precision. {{code|%}} specified an integer, using a single 16-bit word to store values between -32768 and +32767. If a value with more precision was assigned to a variable with less, any excess was simply discarded; {{code|A%{{=}}1.5}} will result in A% having the value 1.


Numeric constants in the [[source code]] could also be specified as a particular type using the same indicators; {{code|50%}} would store the constant as an integer, {{code|0.05!}} or {{code|5E-02}} stores a single-precision value 0.05, and {{code|0.05}} or {{code|5D-02}} stores the same value in the default double-precision format. Vilnius also had the additional ability to allow numeric constants to be typed in as strings of binary, [[octal]] or [[hexadecimal]] characters, by prefixing the string with {{mono|&}} and a single letter indicating the type, B, O, H. For instance, {{code|A{{=}}&H9A8B}} would convert the hexadecimal string H9A8B to the equivalent decimal value 39563 and store that in A.

Operators for numerical values included {{code|+, -, *, /, ^}} adding {{code|\}} for integer division and {{code|MOD}} for the remainder. Thus {{code|5\2}} returns 2, while {{code|5 MOD 2}} returns 1. Numeric functions include the standard {{code|ABS, ATN, COS, EXP, INT, LOG, RND, SGN, SIN, SQR, TAN}}. It also included the {{code|FIX}} operator, which is similar to {{code|INT}} but always truncates toward zero so that {{code|FIX(-1.5)}} returns -1 instead of -2 like INT.

In addition to [[PEEK and POKE]], which returned 16-bit values, the system also offered {{code|OUT and INP}}, which were similar but applied a [[bit mask]] to the values to allow individual bits to be set or cleared.{{sfn|Manual|p=46}} {{code|CLS}} cleared the screen. System functions include {{code|FRE}} which returned the amount of free memory, and {{code|TAB}} which moved to the given column. {{code|AT (x,y)}} worked in a similar fashion to TAB, but moved the cursor to the given X,Y location.

===Strings===
Suffixing a variable with {{code|$}} indicated it was a string. String functions include the common {{code|ASC, CHR$, LEN, STR$, VAL}}. The {{code|STRING$}} function makes copies of a given pattern string so that {{code|A${{=}}STRING$(17, "X")}} will produce a string of 17 X's.{{sfn|Manual|p=44}} Only one manipulation function is included, {{code|MID$}}, which works as in MS, but can also be used to replace characters in an existing string, {{code|MID$(A$,1,1){{=}}"Y"}} will replace the first letter of A$ with Y. {{code|INKEY$}} returns the current key pressed on the keyboard, if any.{{sfn|Manual|p=45}} {{code|+}} was used for [[string concatenation]], as in most dialects.

The {{code|HEX$, OCT$ and BIN$}} functions returned a string encoding the value passed in. For instance {{code|PRINT HEX$(255)}} produces FF, while {{code |PRINT BIN$(255)}} produces 0000000011111111.

===Graphics additions===
The Electronica systems included [[Computer graphics|computer graphic]]s support, and Vilnius BASIC included a number of statements to work with graphics. One interesting feature of this system was that X,Y coordinates were written in parens. The system remembered the last specified point, and new locations could be indicated with the {{code|@}}, for instance, if the last draw command was at (100,100), one could turn the pixel at (105,105) to color 3 with {{code|PSET @(5,5),3}}. There were five color values, 0 through 3.

In addition to {{code|PSET}}, one could draw lines from-to using a pair of coordinates separated by a minus sign, similar to the LIST command, for instance {{code|LINE (100,100)-(120,120),3}}. In its simplest form, {{code|CIRCLE}} took an X,Y pair for the center, a radius, and a color, {{code|CIRCLE (120,120),30,1}}. It could also plot arcs from given start and end angles in radians, {{code|CIRCLE (120,120),30,1,0,1.5}}, and could "compress" the vertical axis to produce an ellipse, {{code|CIRCLE (100,100),20,1,,,0.4}}. {{code|PAINT (100,100),3,1}} performed a [[flood fill]] starting at (100,100), filling with color 3 and moving outward until it saw color 1.

Finally, there was the multi-purpose {{code|DRAW}} command. This took a string which encoded a series of drawing steps that could produce a complex shape in a single line of code. The four cardinal directions were indicated with U, D, L and R (up, down, left, right). The 45-degree angles were, moving clockwise, E (up-right), F, G and H (up-left). For instance, {{code|DRAW "R20D20L20U20"}} would produce a square with sides 20 pixels long starting at the last drawn position. In addition to directions, the M command could be used to specify explicit coordinates, like "M100,120", which did not require the parens. C changes the color, B moves without drawing a line, and N resets the coordinates to what they were before the DRAW command.

There is a single graphics function, {{code|POINT(x,y)}}, which returns the number of the color of that location on the screen.

==Example program==

1 CLS
2 FOR X%=30% TO 1% STEP -2%
3 ? AT(X%,1%);"*"
4 ? AT(X%,20%);"*"
5 NEXT X%

This program clears the screen, creates a loop based on integer values, and then uses the {{code|AT}} command to move the cursor alternately between Y values 1 and 20, printing (using the short form for PRINT, ?) an asterix at both locations. The result is a series of 30 asterixes in two horizontal lines.


== See also ==
== See also ==
* [[List of BASIC dialects]]
* [[List of BASIC dialects]]
* [[List of BASIC dialects by platform]]


==References==
==References==
===Citations===
{{Reflist}}
{{Reflist}}

===Bibliography===
* {{ cite book |author1=Митрюхин, В. К. |author2=Донской, А. Н. |author3=Михайлов, А. В. |author4=Немов, А. М. | title = Программирование на БК-0010-01 | url = http://bk0010.narod.ru/docs/bk-prog.html |trans-title=Programming for BK-0010-01 | language = Russian | year = 1986 | id = version 07.24 |ref=CITEREFManual}}
* {{ cite web | url = http://www.homecomputer.de/pages/easteurope_ussr.html | publisher = HCM - The HomeComputer Museum | location = Germany | title = East-European Home-Computer }}


==External links==
==External links==

Latest revision as of 00:17, 12 March 2024

Vilnius Basic
Paradigmimperative, algorithmic
First appeared1986; 38 years ago (1986)
Dialects
BASIC-86, BASIC-88
Influenced by
MSX BASIC
Influenced
None
Vilnius BASIC on BK-0010-01

Vilnius BASIC, sometimes known as BK BASIC, is a dialect of the BASIC programming language running on the Elektronika BK-0010-01/BK-0011M and UKNC computers. It was developed at Vilnius University, located in Lithuania which was a republic of the Soviet Union at the time.

In contrast to most microcomputer dialects of BASIC of the era, which were interpreters, Vilnius BASIC was a compile and go language that compiled the source when the user entered the RUN command. It was otherwise similar to GW-BASIC and MSX BASIC in style and most features, although it lacked some of the multimedia commands found in MSX. One oddity was that it did not allow more than one statement on a single line, a feature normally implemented using the colon. It also lacked the ability to open more than one data file at a time.

Only the UKNC version had a full-screen editor, versions of the 0010 series machines used a line editor. Machine-dependent features, like graphics operators, parameters, and PEEK/POKE addresses were also different among the machines.

Description

[edit]

Program editing

[edit]

In contrast to most BASIC dialects of the era, Vilnius BASIC was a compile and go system, not an interpreter. When the user types RUN, the compiler reads the code and produces a threaded code executable that it then ran. Nevertheless, this detail was largely invisible to the user, as the system still allowed statements to be typed in without a line number for direct (immediate) mode, or with a number for indirect mode in which case the new line was added to the program or replaced the same-numbered line if it already existed.

By the late 1970s, most microcomputer dialects offered a full-screen editor, in which the user can use the cursor keys to move around the program and type changes into any visible line of code. The Electronica systems were emulating an PDP-11, machines that had been built in the era before cursor-addressable computer terminals were widely available and thus retain the older line editor style. In these systems, a prompt is displayed that allows the user to type in one line of code, or recall a previously typed line and then edit it in-place.

Commands and statements

[edit]

The list of keywords supported in Vilnius can be separated into two groups, those that can only be used in direct mode, and those that can be direct or indirect.

The former, known as commands, included the common CONT, LIST, NEW, RUN. CLOAD and CSAVE load and save programs to cassette tape. AUTO turned on automatic line number entry, RENUM renumbered the lines in the current program, and DELETE deleted ranges of lines using the same "to" format as LIST, for instance, DELETE -200 would delete everything from the start of the program up to an including line 200.

Vilnius' primitives were similar to other BASICs of the era, and supported most of the elementary statements like DATA, DEF FN, DIM, END, FOR..TO..STEP..NEXT, GOSUB, GOTO, IF..THEN with an optional ELSE, INPUT, (optional) LET, LIST, PRINT, ON...GOTO and ON...GOSUB, READ, REM, RESTORE, RETURN, STOP. In contrast to most dialects, Vilnius did not allow more than one statement per line.

Numeric variables, operators and functions

[edit]

As with most dialects, variable names had to start with a letter and could be followed by more letters or digits. Variable names could be any length, but only the first two characters were stored or matched, meaning that typing PRT001=1 followed PR=5 would result in a single variable in memory known as PR with the value 5.

Vilnius BASIC had four basic data types, strings, single and double-precision floating point numbers, and integers. Unless otherwise denoted, variables were assumed to be double-precision, stored in eight bytes and providing about 17 digits of precision. For comparison, most MS dialects used a 5-byte format for floating point. If ! was suffixed to the variable name, the value was stored in single-precision using four bytes with about 7 digits of precision. % specified an integer, using a single 16-bit word to store values between -32768 and +32767. If a value with more precision was assigned to a variable with less, any excess was simply discarded; A%=1.5 will result in A% having the value 1.

Numeric constants in the source code could also be specified as a particular type using the same indicators; 50% would store the constant as an integer, 0.05! or 5E-02 stores a single-precision value 0.05, and 0.05 or 5D-02 stores the same value in the default double-precision format. Vilnius also had the additional ability to allow numeric constants to be typed in as strings of binary, octal or hexadecimal characters, by prefixing the string with & and a single letter indicating the type, B, O, H. For instance, A=&H9A8B would convert the hexadecimal string H9A8B to the equivalent decimal value 39563 and store that in A.

Operators for numerical values included +, -, *, /, ^ adding \ for integer division and MOD for the remainder. Thus 5\2 returns 2, while 5 MOD 2 returns 1. Numeric functions include the standard ABS, ATN, COS, EXP, INT, LOG, RND, SGN, SIN, SQR, TAN. It also included the FIX operator, which is similar to INT but always truncates toward zero so that FIX(-1.5) returns -1 instead of -2 like INT.

In addition to PEEK and POKE, which returned 16-bit values, the system also offered OUT and INP, which were similar but applied a bit mask to the values to allow individual bits to be set or cleared.[1] CLS cleared the screen. System functions include FRE which returned the amount of free memory, and TAB which moved to the given column. AT (x,y) worked in a similar fashion to TAB, but moved the cursor to the given X,Y location.

Strings

[edit]

Suffixing a variable with $ indicated it was a string. String functions include the common ASC, CHR$, LEN, STR$, VAL. The STRING$ function makes copies of a given pattern string so that A$=STRING$(17, "X") will produce a string of 17 X's.[2] Only one manipulation function is included, MID$, which works as in MS, but can also be used to replace characters in an existing string, MID$(A$,1,1)="Y" will replace the first letter of A$ with Y. INKEY$ returns the current key pressed on the keyboard, if any.[3] + was used for string concatenation, as in most dialects.

The HEX$, OCT$ and BIN$ functions returned a string encoding the value passed in. For instance PRINT HEX$(255) produces FF, while PRINT BIN$(255) produces 0000000011111111.

Graphics additions

[edit]

The Electronica systems included computer graphics support, and Vilnius BASIC included a number of statements to work with graphics. One interesting feature of this system was that X,Y coordinates were written in parens. The system remembered the last specified point, and new locations could be indicated with the @, for instance, if the last draw command was at (100,100), one could turn the pixel at (105,105) to color 3 with PSET @(5,5),3. There were five color values, 0 through 3.

In addition to PSET, one could draw lines from-to using a pair of coordinates separated by a minus sign, similar to the LIST command, for instance LINE (100,100)-(120,120),3. In its simplest form, CIRCLE took an X,Y pair for the center, a radius, and a color, CIRCLE (120,120),30,1. It could also plot arcs from given start and end angles in radians, CIRCLE (120,120),30,1,0,1.5, and could "compress" the vertical axis to produce an ellipse, CIRCLE (100,100),20,1,,,0.4. PAINT (100,100),3,1 performed a flood fill starting at (100,100), filling with color 3 and moving outward until it saw color 1.

Finally, there was the multi-purpose DRAW command. This took a string which encoded a series of drawing steps that could produce a complex shape in a single line of code. The four cardinal directions were indicated with U, D, L and R (up, down, left, right). The 45-degree angles were, moving clockwise, E (up-right), F, G and H (up-left). For instance, DRAW "R20D20L20U20" would produce a square with sides 20 pixels long starting at the last drawn position. In addition to directions, the M command could be used to specify explicit coordinates, like "M100,120", which did not require the parens. C changes the color, B moves without drawing a line, and N resets the coordinates to what they were before the DRAW command.

There is a single graphics function, POINT(x,y), which returns the number of the color of that location on the screen.

Example program

[edit]
1 CLS 
2 FOR X%=30% TO 1% STEP -2% 
3 ? AT(X%,1%);"*" 
4 ? AT(X%,20%);"*" 
5 NEXT X% 

This program clears the screen, creates a loop based on integer values, and then uses the AT command to move the cursor alternately between Y values 1 and 20, printing (using the short form for PRINT, ?) an asterix at both locations. The result is a series of 30 asterixes in two horizontal lines.

See also

[edit]

References

[edit]

Citations

[edit]
  1. ^ Manual, p. 46.
  2. ^ Manual, p. 44.
  3. ^ Manual, p. 45.

Bibliography

[edit]
  • Митрюхин, В. К.; Донской, А. Н.; Михайлов, А. В.; Немов, А. М. (1986). Программирование на БК-0010-01 [Programming for BK-0010-01] (in Russian). version 07.24.
  • "East-European Home-Computer". Germany: HCM - The HomeComputer Museum.
[edit]