Features & Software

PSeInt Commands and Syntax: The Complete Reference

Cheat sheet of PSeInt commands such as Definir, Leer and Escribir

PSeInt has a small vocabulary — which is exactly why it is such a good first tool — but students often forget the exact form of an instruction: was it Hasta Que or Hasta? Does Para need Hacer? Which function returns the length of a text? This page answers those questions. It lists every common PSeInt instruction with its English meaning, its syntax and a short example you can run in the online editor.

The syntax shown is PSeInt's flexible default profile. Some courses use stricter profiles (for example, mandatory variable declarations); everything here works in those too, as long as you declare your variables.

Quick translation table

PSeIntEnglishPurpose
Algoritmo / FinAlgoritmoAlgorithm / endProgram frame (also Proceso / FinProceso)
Definir … Como …Define … as …Declare variables and their type
LeerReadInput from the keyboard
EscribirWriteOutput to the screen
<-AssignStore a value in a variable
Si … Entonces … SiNo … FinSiIf … then … elseTwo-way decision
Segun … Hacer … FinSegunSwitch / caseMulti-way decision
Mientras … Hacer … FinMientrasWhile … doLoop checked at the start
Repetir … Hasta Que …Repeat … untilLoop checked at the end
Para … Hasta … Con Paso … HacerFor … to … stepCounting loop
DimensionDimensionCreate an array
Funcion / SubProcesoFunction / subroutineReusable block of code

Program structure

Algoritmo Ejemplo
    // instrucciones
FinAlgoritmo

The name after Algoritmo cannot contain spaces. Functions and subprocesses are written outside the main block, before or after it. Instructions go one per line; a trailing semicolon is optional, and you can place two short instructions on one line by separating them with ;.

Variables and data types

Definir

Definir contador, total Como Entero
Definir precio Como Real
Definir nombre Como Caracter
Definir encontrado Como Logico

Types: Entero (integer), Real (decimal; Numero and Numerico are synonyms), Caracter (text; also Texto and Cadena) and Logico (boolean). Variable names start with a letter and may contain letters, digits and underscores.

Assignment

contador <- 0
precio <- 19.99
nombre <- "Ana"
encontrado <- Falso
total <- contador * 2 + 5

The arrow <- is the standard form; the flexible profile also accepts =. Reading the arrow as "receives" helps: contador receives 0.

Input and output

Escribir

Escribir "Hola"
Escribir "Total: ", total
Escribir Sin Saltar "Ingrese un valor: "

Items separated by commas are printed one after another with no space in between. Sin Saltar keeps the cursor on the same line, which is handy for prompts. Imprimir and Mostrar are accepted synonyms.

Leer

Leer edad
Leer ancho, alto

Leer waits for the user to type a value and press Enter. With several variables, it asks for each value in turn. If the variable was declared as a number and the user types text, PSeInt reports an error.

Operators

CategoryOperatorsExample → result
Arithmetic+ - * / ^2 ^ 3 → 8, 7 / 2 → 3.5
RemainderMOD or %17 MOD 5 → 2
Relational= <> < > <= >=5 <> 3 → Verdadero
LogicalY (&), O (|), NO (~)x > 0 Y x < 10
Text+ joins strings"Hola " + nombre

Order of evaluation, from first to last: parentheses, power, unary minus, * / MOD, + -, relational operators, NO, Y, O. When in doubt, add parentheses.

Conditionals

Si – Entonces – SiNo

Si temperatura > 30 Entonces
    Escribir "Hace calor"
SiNo
    Escribir "No hace calor"
FinSi

The SiNo part is optional. Conditions can be combined with Y, O and NO, and Si blocks can be nested inside each other.

Segun

Segun opcion Hacer
    1:
        Escribir "Nuevo"
    2, 3:
        Escribir "Editar o borrar"
    De Otro Modo:
        Escribir "Opción no válida"
FinSegun

Segun compares one value against a list of options. Several values can share a branch when separated by commas, and De Otro Modo handles everything else. More detail in the conditionals guide.

Loops

Mientras

Mientras saldo > 0 Hacer
    saldo <- saldo - cuota
FinMientras

Checks the condition before each repetition; the body may run zero times.

Repetir – Hasta Que

Repetir
    Escribir "Clave:"
    Leer clave
Hasta Que clave = 1234

Checks the condition after each repetition, so the body always runs at least once. It stops when the condition becomes true.

Para

Para i <- 1 Hasta 10 Con Paso 2 Hacer
    Escribir i
FinPara

Counts from the start value to the end value. Con Paso sets the increment and can be negative to count down; if omitted, the step is 1. See the loops guide for patterns such as counters and accumulators.

Arrays

Dimension notas[30]
Dimension tablero[8, 8]
notas[1] <- 9.5
tablero[2, 3] <- 1

Dimension creates an array with the given size; two sizes create a matrix. In the default profile the first position is 1. Our arrays and matrices guide covers filling, searching and sorting them.

Functions and subprocesses

A SubProceso groups instructions you want to reuse. A Funcion is the same thing that also returns a value: you name the return variable before the function name.

Funcion resultado <- Cuadrado(n)
    resultado <- n * n
FinFuncion

SubProceso Separador
    Escribir "----------"
FinSubProceso

Algoritmo UsarFunciones
    Separador
    Escribir "El cuadrado de 7 es ", Cuadrado(7)
    Separador
FinAlgoritmo

Parameters are passed by value by default (the function gets a copy). Write Por Referencia after a parameter so the function can modify the caller's variable — the classic example is swapping two values. Arrays are always passed by reference.

SubProceso Intercambiar(a Por Referencia, b Por Referencia)
    Definir aux Como Real
    aux <- a
    a <- b
    b <- aux
FinSubProceso

Algoritmo Prueba
    Definir x, y Como Real
    x <- 1
    y <- 2
    Intercambiar(x, y)
    Escribir x, " ", y
FinAlgoritmo

Built-in mathematical functions

FunctionReturnsExample
RC(x) or RAIZ(x)Square rootRC(81) → 9
ABS(x)Absolute valueABS(-4) → 4
TRUNC(x)Integer partTRUNC(7.9) → 7
REDON(x)Nearest integerREDON(7.5) → 8
AZAR(n)Random integer from 0 to n-1AZAR(6) + 1 → a die roll
ALEATORIO(a, b)Random integer from a to bALEATORIO(1, 100)
LN(x), EXP(x)Natural log, exEXP(1) → 2.718…
SEN COS TANTrigonometry (radians)SEN(PI / 2) → 1
ASEN ACOS ATANInverse trigonometryATAN(1) → 0.785…
PIThe constant π2 * PI * r

Built-in text functions

FunctionReturnsExample
LONGITUD(s)Number of charactersLONGITUD("Hola") → 4
MAYUSCULAS(s)Upper caseMAYUSCULAS("pse") → "PSE"
MINUSCULAS(s)Lower caseMINUSCULAS("INT") → "int"
SUBCADENA(s, i, j)Characters from position i to jSUBCADENA("PSeInt", 1, 3) → "PSe"
CONCATENAR(a, b)Joined textCONCATENAR("Ho", "la") → "Hola"
CONVERTIRANUMERO(s)Number from textCONVERTIRANUMERO("42") → 42
CONVERTIRATEXTO(x)Text from numberCONVERTIRATEXTO(3.5) → "3.5"

Positions in SUBCADENA start at 1 in the default profile (some strict profiles start at 0).

Other useful instructions

  • Borrar Pantalla (or Limpiar Pantalla) clears the console.
  • Esperar Tecla pauses until the user presses a key.
  • Esperar 2 Segundos (or Milisegundos) pauses for a fixed time — nice for simple animations and countdowns.

Comments and documentation

Everything after // on a line is a comment. Use comments to explain why something is done, not to repeat the code. A short header comment with the purpose of the algorithm, the author and the date is a good habit for assignments:

// Calcula el promedio de un curso y la cantidad de aprobados.
// Autor: Ana Pérez — 2026
Algoritmo PromedioCurso
    // ...
FinAlgoritmo

Syntax profiles

The desktop PSeInt lets each course choose a profile that adjusts the rules. Typical settings include:

  • whether every variable must be declared with Definir before use;
  • whether arrays and string positions start at 0 or at 1;
  • whether instructions must end with a semicolon;
  • whether = may be used for assignment or only <-.

If a program that works for a classmate fails for you with a strange syntax error, compare your profiles first. Writing in the strictest style — declare everything, use <-, close every block explicitly — produces code that works under any profile.

Common error messages and what they mean

SituationLikely causeFix
A block is reported as not closedA Si, Para or Mientras without its Fin…Format the code and look for the misaligned block
Variable without a valueReading a variable before assigning itInitialise it (x <- 0) or read it first
Type mismatchText stored in a number, or a decimal in an EnteroCheck the declaration and the quotes; use TRUNC or REDON
Index out of rangeArray position below 1 or above its sizeCheck the loop limits, especially with v[i + 1]
Condition is not logicalA number used where a true/false value is neededCompare it: Si x <> 0 Entonces
Division by zeroDivisor equal to 0 at run timeCheck the divisor with Si before dividing

Reserved words you cannot use as names

Keywords such as Si, Para, Leer, Fin…, the type names, Verdadero, Falso and the built-in function names are reserved. Using them as variable names leads to confusing errors, so avoid names like si, leer or longitud. A safe convention is to use descriptive nouns: cantidadAlumnos, precioUnitario, esValido.

Translating PSeInt to real languages

Every structure in this reference has a direct equivalent in mainstream languages. Escribir becomes print in Python or System.out.println in Java; Si … SiNo becomes if … else; Mientras becomes while; Para becomes for; Dimension v[10] becomes an array or list. The desktop PSeInt can perform this translation automatically, which is a great way to see the same algorithm written in a professional language once you've mastered the logic.

Putting it together

This program uses almost every category in this reference: declarations, input, a loop, a condition, a function and text functions.

Funcion r <- EsVocal(c)
    c <- MINUSCULAS(c)
    r <- c = "a" O c = "e" O c = "i" O c = "o" O c = "u"
FinFuncion

Algoritmo ContarVocales
    Definir frase Como Caracter
    Definir i, vocales Como Entero
    Escribir "Escriba una frase:"
    Leer frase
    vocales <- 0
    Para i <- 1 Hasta LONGITUD(frase) Hacer
        Si EsVocal(SUBCADENA(frase, i, i)) Entonces
            vocales <- vocales + 1
        FinSi
    FinPara
    Escribir "La frase tiene ", vocales, " vocales"
FinAlgoritmo

Type a sentence such as "Programar es divertido" and the program reports 8 vowels. (Accented vowels such as "á" are not counted by this simple version — a good exercise is to add them.)

Style rules that make programs readable

  • Indent the body of every block by four spaces.
  • Use descriptive names: precioFinal instead of pf.
  • Declare all variables at the top of the algorithm.
  • Prompt before every Leer.
  • Add a comment above each logical part of a long algorithm.

Frequently asked questions

What is the difference between SubProceso and Funcion?

In current PSeInt they are the same construct: Funcion, SubProceso and SubAlgoritmo are interchangeable keywords. By convention, a block that returns a value (with resultado <- Nombre(…) in its header) is called a function.

Can I use = instead of <- ?

In the flexible profile, yes. Inside a condition, = means comparison. Using <- for assignment avoids confusion and works in every profile.

Is there a "Retornar" instruction?

Standard PSeInt returns values through the variable named in the function header. Our online editor additionally accepts Retornar valor as a shortcut, but for maximum compatibility use the return variable.

Why does PSeInt say my variable has no value?

You are reading a variable before assigning anything to it. Give it an initial value — for example suma <- 0 before a loop.