This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
examples [2020/02/15 09:18] adminz |
examples [2020/02/21 09:23] (current) jtwine |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== Hello World! ===== | ===== Hello World! ===== | ||
- | Well, no introduction to any programming language would be complete without the traditional and ubiquitous **Hello World!** example. So, here 'ya go! | + | Well, no introduction to any programming (or scripting) language would be complete without the traditional and ubiquitous **Hello World!** example. The basic unit of code in 10LC is called a **Program**. You can have multiple programs in a single file, if you wish. Programs are //opened// via the ''Program'' statement, and //closed// with the ''EndProgram'' statement. So, here 'ya go! First |
- | <code> | + | <code c> |
Program HelloWorld; | Program HelloWorld; | ||
Display "# - Hello World - "; | Display "# - Hello World - "; | ||
+ | EndProgram; | ||
</code> | </code> | ||
The above program, when compiled and executed on the 9010A, will emit a beep and display ''- HELLO WORLD - ''. Note the trailing space - 10LC performs automatic conversion of trailing spaces (in display strings) to underscore characters so that they display correctly on the 9010A's display. Also, just like in 9LC, the pound/hash sign (''#'') is used with the display to cause the 9010A unit to beep. | The above program, when compiled and executed on the 9010A, will emit a beep and display ''- HELLO WORLD - ''. Note the trailing space - 10LC performs automatic conversion of trailing spaces (in display strings) to underscore characters so that they display correctly on the 9010A's display. Also, just like in 9LC, the pound/hash sign (''#'') is used with the display to cause the 9010A unit to beep. | ||
+ | |||
+ | |||
+ | ==== Basic Loops ==== | ||
+ | Loops in 10LC are constructed using Labels, ''Goto'' statements, and ''If'' statements. For example, here is the implementation of a simple delay loop: | ||
+ | |||
+ | <code c> | ||
+ | :Delay // Delay Routine, Register F Contains The Delay Value | ||
+ | --RegF; // Decrement Delay Counter | ||
+ | If RegF > 0 Goto Delay; // If Greater Than Zero, Go Back To Start Of Loop | ||
+ | // End | ||
+ | </code> | ||