This is the forum post for the Scratch Operating System, Dvbris OS, created by Grit96 and Olls.
Dvbris OS Programmer v1.0
This is the most advanced version of Dvbris OS yet. It is a simple program interpreter and executor that will run basic programs.
Documentation
1: Running a program:
When you have a program loaded into the program list, you can run it by pressing space. This will visually cycle through the program list, executing each command separately. If the program contains a return function ( rtn() ), then you will see an output from the program in the log. Any errors in the program will be put into the error log.
2: Loading a program from memory:
To load a program from the program index list, hit the l key. You will then be presented with an ask box, in which you will type the name of the program you wish to load. Make sure you type it exactly as it is in the index because the program names are case-sensitive. The program will then begin to load into the program list.
3: Exporting a program:
If you wish to export the program to use at another time, or for editing, right-click on the program list and select export. This will save the program as a text file which can be later imported back into Dvbris OS Programmer.
4: Importing a program:
You can import a program into the program list by right-clicking on the program list and selecting import. Then import the text file with a program saved in it. This could be one you exported earlier, or one you wrote in a text editor. Now you can export, edit or run your program.
5: Saving a program to memory:
Once you have written your program and imported it into the program list, you can save it into the program index list by tapping the s key. You will then enter the name for the program. Now you can load the program from memory.
6: Writing a program:
Open notepad, or any text editor to write your program. Use the following functions to write your program:
sum(a,b) adds a and b.***
mul(a,b) multiplies a and b.***
div(a,b) divides a by b.***
sub(a,b) subtracts a from b.***
jin(a,b) joins string a to string b.***
mod(a,b) modulates a by b.**
rdm(a,b) finds a random number between a and b.**
rnd(a) rounds a.*
sqt(a) finds the square root of a.*
sin(a) finds sine of a.*
cos(a) finds cosine of a.*
tan(a) finds tangent of a.*
abs(a) finds the absolute number of a.*
ask(a) asks the user the question a and outputs there reply.*
rtn(a) returns a to the log.*
* only one parameter allowed
** only two parameters allowed
*** infinite parameters allowedUse one function per line, with no spaces outside the function, or blank lines. The only characters allowed in a parameter are the characters A-Z, a-z, 0-9, and all the symbols scratch will normally accept, except the tick (`) character and either of the brackets. The dollar character ($) can not be used as the first character of a parameter. In the mathematical functions, only numbers are allowed. The output of each line is put into a variable automatically, labelled by the line number. You can then use this variable on another line as a parameter by putting the $ key in front of the line number you want the result from. For Example, the following program works out (15+5)/2:
sum(15+5)
div($1,2)That program only works out the answer, if you run it you would not get any output, because if you want to show the user output, you need to use the rtn() function to return something to the log. For example:
sum(15+5)
div($1,2)
rtn($2)This would now output 10 to the log.
If you want to have user interaction, which is what makes your programs do anything useful, you use the ask() function to get information from user. You can then use the jin() function to join strings of text together, for example, the following program is one already saved on the project as 'Adder', it adds the two numbers the user puts in:
rtn(Welcome to the adder.)
ask(Please enter the first number, then press enter.)
ask(Please enter the second number, then press enter.)
sum($2,$3)
jin(The sum of ,$2, and ,$3, is ,$4,.)
rtn($5)You can make much more sophisticated programs in exactly the same way, just make sure you only have one function per line. For example, this is the second program already saved on the project as 'Age Finder':
ask(What year where you born?)
ask(What month where you born?)
ask(What year is it now?)
ask(What month is it now?)
div($2,12)
div($4,12)
sum($5,$1)
sum($6,$3)
sub($8,$7)
mul($9,100)
rud($10)
div($11,100)
jin(You are ,$12, years old!)
rtn($13)See if you can work out exactly what each line does and how, then try writing your own programs! To import and run your program, please see section one and four of the documentation.
Offline