Open BASIC Programming Language

Published 2016-10-09
=================~INTRODUCTION~=================

Welcome to Open BASIC, a simple text-based language. Open BASIC is easy to use but can support the most complex of programs! Because it is a high-level language with minimal syntax, you won't have to worry about using the wrong data type or finding the missing semicolon somewhere on line 97.

Open BASIC's easy-to-read manual contains everything you could possible want to know combined with plentiful examples, so what are you waiting for! Start programming with Open BASIC today!

I would like to thank @oblatespheroid for making Hull, the project which I based the UI off of.

====================~MANUAL~====================

In Open BASIC every line of code contains a command and (in some cases) an argument, similar to assembly language. Below is listed every command. Examples for how to use them will be provided.

=====================~PRINT~=====================

print [argument] - appends [operand] to output.

Input:
print Hello, world!

Output:
Hello, world!

=====================~SLEEP~====================

sleep [number] - pauses for [number] seconds.

Input:
print 3
sleep 1
print 2
sleep 1
print 1

Output:
3 (1 second pause)
2 (1 second pause)
1

=====================~STOP~=====================

stop - aborts execution of the program.

Input:
print sham
stop
print wow

Output:
sham

===================~COMMENTS~===================

//comment - place two slashes at the beginning of any line to make it not run

Input:
print sham
//print wow

Output:
sham

====================~DELETE~====================

delete [number] - deletes the output at line [number]

Input:
print sham
print wow
delete 1

Output:
wow

=================~EDITING TRICKS~=================

* Let's be honest, the Scratch editor is a lot better. I recommend going inside the project and editing the list directly.
* Delete all lines at once by pressing the delete button and entering all.
* You can also enter last to delete the last line.
* Later, you learn that this also works on commands such as replace and insert.

====================~RANDOM~====================

\d - random number 0 to 9 (must be part of operand!)
\b - random number 0 to 1 (must be part of operand!)

Input:
print Random Digit: \d
print Random Binary Number: \b

Output:
Random Digit: 7
Random Binary Number: 1

Output:
Random Digit: 4
Random Binary Number: 0

=====================~GOTO~=====================

goto [number] - goes to line [number]

Input:
print this is line 1
goto 4
print this is line 3
print this is line 4

Output:
this is line 1
this is line 4

Input:
//prints a bunch of random digits
print \d\d\d\d\d\d\d\d\d\d
//restarts program from beginning, causing infinite loop
goto 1

Output:
8051189042
2797639811
0186726652
...
(this will go on forever until you click the pause or stop button)

====================~REPLACE~====================

replace [number], [argument] - replaces line [number] in output with [argument]

Input:
print sham
print wow
sleep 1
//replace actually accepts 2 arguments separated by a comma
replace 1, wow

Output:
wow
wow

==================~LINE NUMBER~==================

\n - gets current line number

====================~INSERT~====================

insert [number], [argument] - inserts [argument] before line [number]

Input:
print line \n
print line \n
//will get pushed to line 4
print line \n
sleep 1
//will appear in line 3 of output
insert 3, shamwow

Output:
line 1
line 2
shamwow
line 3

===================~VARIABLES~===================

set [variable] = [argument] - creates or sets a variable [variable] equal to [argument]

Input:
//variables replace all cases of their names surrounded by percent signs with their values
// to display percent signs normally, use \%
set hi = hello
print %hi%
set hi = 5
print %hi%

Output:
wow

=====================~MATH~=====================

add [variable], [number] - adds [variable] to [number] and stores it back into [variable]

sub [variable], [number] - subtracts [variable] by [number] and stores it back into [variable]

mul [variable], [number] - multiplies [variable] by [number] and stores it back into [variable]

div [variable], [number] - divides [variable] by [number] and stores it back into [variable]

Input:
set var = 2

//2 + 5 = 7
add var, 5
print %var%

//7 - 3 = 4
sub var, 3
print %var%

//4 * 5 = 20
mul var, 5
print %var%

//20 ÷ 2 = 10
div var, 2
print %var%

Output:
7

===============~DESCRIPTION LIMIT~===============

lol I reached the maximum size for a Scratch project description, so the rest of the manual can be found inside of a comment.

1. Click "See inside"
2. Click "Stage"
3. Scroll down until you get to the section on input
4. Have fun programming! :)