Logic Basic tutorial for beginners
The Logic Basic has a command called Message, identical to the Write command, except that it does not write directly in the main window, but in a small box message centered on the video monitor:
Message "Any phrase..."
The command Window performs various settings in the main window of the Logic Basic, such as size, background color, background images, character font, and so on.
For example, to set the background color of the window as white, just inform the argument Background, and assign the desired color:
Window Background = White
To set a background image to the window, instead of color must enter the path and name of an image file, for example:
Window Background = "C:\Pictures\Landscape.jpg"
There are several other configuration options that can be entered on the same line in sequence, but they must be separated by commas, for example:
Window Res = 50,150, size = 30,100, Pos = 0,0
In the above example the command "Window" sets the window resolution with 50 rows by 150 columns, the window size to 30 rows by 100 columns, and position of the window on the desktop of Windows from line 0, column 0.
An important detail is that the size and position depend on the window resolution, which is calculated according to the current size of the window, so this must be set first.
The Font command defines the character font of the window such as name, size, color, and so on. After defining the source, all texts written in the window will have the attributes defined by this command.
In Logic Basic new windows may exist beyond the main window (created by the command NewWindow that will explain later) and each one has its name, it was agreed that the name of the main window will be Parent. So to set a font attribute in the main window, you would type the command Font, then the window name with a dot, the name of the attribute and its value, for example:
Font Parent.Name = "Arial"
Font Parent.Color = Blue
Font Parent.Size = 20
Position 5,10; Write "Logic Basic"
If the window name is omitted in the Font command, the Logic Basic assumes the name of the main window (Parent), for example:
Font Name = "Arial"
The ClearWindow command deletes all texts and drawings in the active window, except the background and components placed on it. This command has no argument:
You can also use the Cls command, which is similar to the ClearWindow command:
You can make comments in the program code, they will not produce any effect on the program, it is as if they did not exist in the program code.
To make a comment, you must write the sign ' (apostrophe) at the beginning of the line, or after any command line, all text written after this signal is ignored:
Write "Hello world!" 'Write the phrase "Hello World!" in the active window
In the example above, the text written after the command Write "Hello World" will be ignored.
When you put ; (semicolon) after a command, you can then write another command on the same line. This improves the clarity of the program, and also decreases the number of lines. In fact, for the Logic Basic, each command separated by semicolon is considered as a new line. That way, you can put multiple commands on one line, for example:
Position 11,33; Write "Hello, World!"
The commands EndProgram and EndWindow terminates the execution of the program in the line where they are placed.
The command EndProgram just ends the program, but retains the main window active. The command EndWindow ends the program and closes all active windows. Note that you must choose only one of them to terminate the program.