PSeInt SubProceso: how to write and call a procedure
Groups instructions under a name so you can use them whenever you want, like a recipe. It can receive data (parameters) to work with.
- Group:
- Structures
- Template
SubProceso
Opens the editor with this example loaded. Run it step by step and watch the flowchart.
Worked example
A complete algorithm, ready to copy and run.
SubProceso Saludar(nombre) Escribir "Hola, ", nombreFinSubProcesoAlgoritmo Example Saludar("Ana")FinAlgoritmoOutput
Then Saludar("Ana") shows "Hola, Ana".
This is what the console shows when the example runs.
Hola, AnaCommon mistake
A Por Referencia parameter lets the subprocess change the original variable.
In a flowchart
This is how it appears in a flowchart, with the same shapes Codoritmo draws.
Template
The general form. Replace what's inside < > with your own data.
SubProceso Nombre(<parametro>) <acciones>FinSubProcesoExamples that use it
Programs from the example library where it appears, from the simplest to the most complete.
Bubble Sort
Sorts random numbers by swapping neighbors, and stops as soon as they're in order.
IntermediateSelection Sort
Finds the smallest of the remaining numbers and puts it in its place.
IntermediateInsertion Sort
Inserts each number among the sorted ones, like arranging cards in your hand.
IntermediateCounting Sort
Counts how many times each value appears, without comparing numbers.
IntermediateBinary Search
Finds a value in a sorted array by halving the range every step.
IntermediateLinear vs. Binary Search
Counts the comparisons each search needs on the same sorted list.
Intermediate
More structures
Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.