01 · Overview
About Logic Basic
Logic Basic is a programming language paired with a visual environment: besides code, a program can interact with a window, controls, drawings, sounds, and data files. The author's manual introduces it through commands and progressive exercises for beginners.
This reference summarizes concepts and forms of writing documented in the manual consulted. Since the material is organized around commands and environment features, use the source for details of each visual option.
02 · Organization
Program, window, and file
The manual describes two work areas: the code and the window where the program displays results and controls. Execution proceeds through the code until the end or until FimPrograma or FimJanela. Source files use the .LBC extension.
A line can contain multiple commands separated by semicolons; each separated command is treated as a logical line. An apostrophe begins a code comment.
Memoria Nome
Nome = "Ana"
Posicione 1, 1
Escreva "Hello, ", Nome
FimPrograma03 · Data
Memory values
Memoria creates names used to store values. The manual recommends putting these declarations at the beginning of the main code. A memory value can hold text, numbers, and visual-environment items such as objects and sounds. The same name can receive a new value during execution.
Memoria Nome, Pontos, Fundo
Nome = "Ana"
Pontos = 12
Fundo = "fundo-verde"Text is quoted. An unquoted number is numeric and can be used in calculations; a quoted number is text. The manual uses a comma as the decimal separator, for example 3,5. Memory names cannot contain spaces.
04 · Expressions
Assignment and operators
Outside a condition, = assigns a value. Inside a condition, = compares values. The language documents arithmetic operations, compound updates, and comparisons. The manual's examples use SIM and NAO for logical values.
| Group | Documented forms | Use |
|---|---|---|
| Arithmetic | + - * / % | Calculations and remainder. |
| Updates | ++ -- += -= | Increment, decrement, or update a value. |
| Comparison | = < > <= >= <> | Test equality and ordering in a condition. |
| Logical | E OU | Combine conditions. |
Memoria X, Y, Soma
X = 8
Y = 3
Soma = X + Y
Soma += 1
Se Soma >= 12
Escreva "Reached the value"
FimSeOperators and numeric handling follow the Logic Basic manual. Command spelling in examples follows the forms shown by the author.
05 · Interaction
Input, messages, and output
Escreva displays one or more items in the window in sequence. Posicione sets the output position and LimpaJanela clears the visual area. Mensagem displays a dialog message.
EntraTexto prompts for text and returns the input to a memory value. The manual also describes controls such as text boxes, lists, options, and check boxes; their values can be read with Componente Valor.
Memoria Nome
Nome = EntraTexto, "Enter your name:"
LimpaJanela
Posicione 1, 1
Escreva "Hello, ", Nome
Mensagem "Entry complete"06 · Decisions and repetition
Se, CasoContrario, and VaPara
Se executes statements when a condition is true. CasoContrario defines an optional alternative and FimSe closes the block. For repetition, the manual presents labels and VaPara, which transfers execution to a named line.
Memoria Tentativa
Tentativa = 0
INICIO
Tentativa = Tentativa + 1
Escreva "Attempt ", Tentativa
Se Tentativa < 3
VaPara INICIO
CasoContrario
Escreva "Attempts complete"
FimSeThis form can create loops, but it requires explicit control of the state that ends repetition. An incorrect jump can make the program repeat forever.
07 · Reuse
Functions and extensions
The manual describes named routines outside the main flow. Execute Name() calls a routine, and Retorne returns execution to the command after the call. A routine can call other routines and can be recursive. The material also presents extension panels for organizing reusable code.
Escreva "Before the routine"
Execute Saudacao()
Escreva "After the routine"
FimPrograma
Saudacao()
Escreva "Hello!"
RetorneUse consistent routine names and make sure every execution path that enters a routine reaches Retorne, so it does not continue into unrelated code.
08 · Collections
Matrices
A memory value can be declared with a number of positions in parentheses. Indices start at zero. For example, Memoria Nome(20) creates positions from Nome(0) through Nome(19). A numeric value can serve as an index inside a loop.
Memoria Nome(3), I
Nome(0) = "Ana"
Nome(1) = "Beto"
Nome(2) = "Caio"
I = 0
INICIO
Escreva Nome(I)
I = I + 1
Se I < 3
VaPara INICIO
FimSeProcureMatriz searches for a value in a matrix and returns its matching index; the manual says it returns -1 when the value is not found.
09 · Visual features
Window, controls, and media
Visual commands can position text, draw objects, display images, and respond to interactions. Componente creates form controls; Desenhe displays objects or visual resources; Aguarde pauses execution or receives an interaction, depending on the arguments documented in the manual.
The material also covers mouse input, sound, and video. Channels, positions, dimensions, and controls depend on each command's parameters; consult the source before using advanced options.
LimpaJanela
Posicione 5, 5
Desenhe "personagem"
Aguarde10 · Persistent data
Native database
The manual describes BD ... FimBD blocks for defining fields and AbreBD for opening a data file. Fields are populated through the database and field names; AdicionaRegistro saves a record, LeRegistro reads by position, and FechaBD closes the file. Commands for sorting, searching, and counting records are also documented.
| Command | Purpose in the manual |
|---|---|
BD ... FimBD | Define a table's fields. |
AbreBD / FechaBD | Open or close the associated file. |
AdicionaRegistro | Save populated fields as a new record. |
LeRegistro | Read a record by position. |
OrdemBD, Procure | Sort or locate records. |
TotalRegistros | Get the number of records. |
The database uses its own files and a field definition. Follow the manual's open and close sequence before reading or saving records.
11 · In practice
Integrated example
This example uses memory values, input, and a condition to display a personalized greeting. It brings together basic commands without depending on advanced graphics.
Memoria Nome, Pontos
Nome = EntraTexto, "What is your name?"
Pontos = 0
LimpaJanela
Posicione 1, 1
Escreva "Welcome, ", Nome
Se Nome = ""
Mensagem "Enter a name to continue"
CasoContrario
Pontos = Pontos + 1
Escreva "Points: ", Pontos
FimSe
FimPrograma12 · Sources
Manual consulted
- Logic Basic manual by Eleusmário Mariano Rabelo — reference for commands, memory values, interface, matrices, routines, and database.
Examples on this page were written to explain the concepts; consult the original manual for every parameter of each command.