01 · Overview
About Mapler
Mapler is an educational Portugol variant: its commands describe algorithms in structured Portuguese and organize them into readable blocks. The primary reference is the Mapler project manual, supplemented by its official examples for structure, types, operations, decisions, loops, and modules.
This page describes Mapler specifically. Its rules do not define a single syntax for the other variants in the Portugol family.
02 · Organization
Program structure
A program has a variaveis area, an executable block introduced by inicio, and the closing marker fim. Declarations go before the main algorithm; modules are declared in that area and defined after the main block.
variaveis
nome: cadeia;
idade: inteiro;
inicio
escrever "What is your name?";
ler nome;
escrever "Hello, ", nome;
fim.The period after fim appears in the project's structure examples. Commands inside blocks end with semicolons.
03 · Data
Variables, types, and vectors
A declaration places a colon and type after the variable name inside variaveis. Documented types include inteiro, real, logico, caractere, and cadeia. Use verdadeiro and falso for logical values; text is quoted and individual characters use character literals.
variaveis
tentativas: inteiro;
media: real;
aprovado: logico;
inicial: caractere;
mensagem: cadeia;
notas: vetor [1..5] de real;
inicio
tentativas <- 0;
aprovado <- falso;
notas[1] <- 8.5;
fimVector bounds are written in square brackets. The official example starts at 1; use indices within the declared bounds.
04 · Calculations
Assignment and operators
Assignment uses <-. The mathematics reference documents addition, subtraction, multiplication, and division with +, -, *, and /. Expressions can combine variables, literals, and parentheses; use parentheses to make the intended order explicit.
| Group | Forms | Use |
|---|---|---|
| Arithmetic | + - * / | Add, subtract, multiply, and divide numbers. |
| Relational | = <> < <= > >= | Compare values in conditions. |
| Logical | e ou nao | Combine or negate logical conditions. |
total <- preco * quantidade;
se total >= limite entao
escrever "Over the limit";
fim se;05 · Interaction
Input and output
escrever displays text or values in the terminal and accepts multiple items separated by commas. ler reads a value from the keyboard and stores it in the named variable.
variaveis
nome: cadeia;
idade: inteiro;
inicio
escrever "Name:";
ler nome;
escrever "Age:";
ler idade;
escrever nome, " is ", idade, " years old.";
fimThe variable type should match the value entered. A prompt before ler makes the expected input clear.
06 · Decisions
Conditions with se and senao
se evaluates a condition; entao starts the block that runs when the condition is true. The optional senao introduces the alternative. Every conditional block ends with fim se;.
se nota >= 7 entao
escrever "Passed";
senao
escrever "Keep studying";
fim se;Conditions may be nested as long as each block closes before its parent. Relational and logical operators can form compound expressions.
07 · Repetition
para, enquanto, and repita loops
para traverses a range with a control variable, start, end, and step. enquanto checks its condition before each iteration. repita runs its block and checks the condition afterward, so the body runs at least once.
variaveis
i: inteiro;
inicio
para i de 1 ate 5 passo 1 faca
escrever i;
fim para;
i <- 1;
enquanto i <= 5 faca
escrever i;
i <- i + 1;
fim enquanto;
repita
i <- i - 1;
ate i = 0;
fimBlocks close with the command name in fim para; and fim enquanto;. Choose a step and condition that let the loop reach its intended end.
08 · Reuse
Modules
Modules are named blocks defined outside the main program and called by name. They are declared in variaveis with the type modulo; the official reference says modules can access variables in the main block.
variaveis
dizerOla: modulo;
inicio
dizerOla;
fim
modulo dizerOla;
escrever "Reusable routine";
fim modulo;This form organizes repeated tasks. Mapler's material presents modules without parameters; they are different from functions in other variants.
09 · In practice
Complete example
This example combines declarations, input, a calculation, and a decision. It uses structures described in the Mapler reference.
variaveis
valor_a: real;
valor_b: real;
media: real;
inicio
escrever "First value:";
ler valor_a;
escrever "Second value:";
ler valor_b;
media <- (valor_a + valor_b) / 2;
escrever "Average: ", media;
se media >= 7 entao
escrever "Sufficient result";
senao
escrever "Review the material";
fim se;
fim.10 · Files
File extension in Potoo IDE
The Mapler manual describes source text files with a .txt extension. Potoo IDE uses .mapler for Mapler files, a choice inspired by the DesignLiquido/mapler project. That repository is cited only as background for the adopted extension; syntax and features on this page come from Mapler's official manual and examples.
11 · Sources
References
- Mapler user manual — purpose, editing, execution, and debugging.
- Code structure, types and vectors, operations, input and output, conditions, loops, and modules.
- DesignLiquido/mapler — inspiration for the
.maplerextension used by Potoo IDE.