Ozapell Basic Learn Programming #4

A computer program is a series of instructions that run sequentially.

There are three broad categories of instructions:

  1. Data Manipulation
  2. Logic
  3. I/O (Input/Output)

Data manipulation includes the assignment of data to a variable (X=10), the copying of data between variables (Y=X), as well as mathematical operations on the data.

Logic would include any instruction that makes a decision based on data provided.

Input would include instructions that collect data from various sources such as a key press from the keyboard (INPUT) or a text file from a hard drive.

Output would include instructions that display text (PRINT) or graphics on the screen or write a text file to a hard drive.

Example:

REPEAT

INPUT

UNTIL RESULT

PRINTLINE RESULT

In this example program, the REPEAT and UNTIL will loop while waiting for a key press. While no key is pressed, the variable RESULT will be an empty string. An empty string in Ozapell Basic equates as FALSE. Any key press will equate as TRUE. UNTIL will jumpĀ  back to its REPEAT until RESULT equals TRUE. After a key is pressed, the variable RESULT is copied to the variable TEXT. PRINTLINE uses TEXT to display the key pressed.

Ozapell Basic on Steam

 

Advertisements
Ozapell Basic Learn Programming #4

Ozapell Basic Learn Programming #3

The FOR NEXT loop is a simple way to loop through one or more instructions for a specified number of times.

Example:

FOR X=1 to 12

PRINTLINE X

NEXT X

In this example, the numbers 1 through 12 will be displayed when the program is run. The variable X is first assigned the value of 1. When the program reaches NEXT X, the value in X is increased to 2 and the current position in the program jumps back to the FOR statement.

In Ozapell Basic, FOR NEXT loops can also decrease in value.

For example,

FOR Y=12 to 1

PRINTLINE Y

NEXT Y

In this example, the numbers 12 through 1 will be displayed when the program is run. Ozapell Basic determines that each NEXT Y will decrease the value in Y based on the values in the FOR statement.

The values used in a FOR statement must be integers (whole numbers) including 0 and negative numbers.

Example:

FOR Z=-5 TO 5

PRINTLINE Z

NEXT Z

When the program is run, the numbers -5 through 5 will be displayed including the 0 in the middle.

Finally, it should be noted that the values provided in the FOR statement can also be variables when the range needed is not known until run-time. This would be useful when looping through a line of text where the length of the text isn’t known to the programmer.

Partial example:

FOR C=0 to L

NEXT C

In this partial example, the variable C will first be assigned the value of 0 and then loop until C reaches the value contained in the variable L.

Ozapell Basic on Steam

 

Ozapell Basic Learn Programming #3

Ozapell Basic Learn Programming #2

There are several subroutines for displaying text on the screen or clearing the screen in Ozapell Basic. A few a explained here.

To display a line of text on the screen and then starting a new line for text, use PRINTLINE.

Example:

TEXT=”HELLO”

PRINTLINE

In this example, the variable TEXT is assigned the string HELLO. The subroutine PRINTLINE uses the variable TEXT. The string contained in TEXT will be displayed on the screen by PRINTLINE.

In order to display a string of text without starting a new line, use PRINT.

As a shortcut, PRINT and PRINTLINE can also be used like this:

PRINTLINE “HELLO”

PRINT X

In this example, the text string “HELLO” will be copied to the variable TEXT and then PRINTLINE will use it to display. Then the content of the variable X will be copied to TEXT and displayed by PRINT.

To clear the screen, use CLS.

Example:

CLS

This will clear the screen. The colors on the screen will be changed based on the current settings in TEXTCOLOR and BACKCOLOR.

TEXTCOLOR and BACKCOLOR are variables used by most display subroutines to determine what colors to use.

TEXTCOLOR is the foreground color. BACKCOLOR is the background color.

There are several colors predefined by Ozapell Basic.

For example:

TEXTCOLOR=COLORWHITE

BACKCOLOR=COLORBLACK

The foreground color is set to white while the background color is set to black.

Ozapell Basic on Steam

 

Ozapell Basic Learn Programming #2

Ozapell Basic Learn Programming #1

A variable is a symbol representing a quantity.

In computer programming, a variable represents a location in memory where a value is stored.

In Ozapell Basic, there are four simple types of variables. The type of the variable is determined by the data assigned to it.

For example:

X=10

X is a variable assigned the value of 10. X is of the integer type because it is a whole number (doesn’t contain a decimal point). 0 is also an integer. Negative whole numbers such as -1 or -50 are also integers.

Another example:

Y=10.5

Y is a variable assigned the value of 10.5. 10.5 is a floating point number because it contains a decimal point. 0.0 is also a floating point number as long as the decimal point is included. Negative floating point numbers contain a decimal point such as in -1.5 or -50.33.

Another example:

Z=”HELLO”

Z is a variable assigned the text string HELLO. (Note: The quotation marks designate the begin and end of the string. These quotation marks are not included in the final string.)

Finally, the fourth simple type in Ozapell Basic is a boolean. Boolean variables contain either TRUE or FALSE. They are used by logic statements.

Example:

B=TRUE

B is a variable assigned the boolean value of TRUE.

Ozapell Basic on Steam

Here are some videos demonstrating how to start working with Ozapell Basic.

 

 

 

Ozapell Basic Learn Programming #1