Functions / Subprocesses
Funcion variable_de_retorno <- nombre_de_la_funcion ( argumento_1, argumento_2, ... )
// codigo..
FinFuncion
Start with keyword Funcion
(alternatively you can use SubProceso
or SubAlgoritmo
, they are synonymous) followed by the return variable, the assignment sign, the name of the subprocess, and finally, the list of arguments in brackets. There are variants for this structure.
-
If the function does not return any value, the variable of
return and the assignment sign. That is, it can be placed
directly the name and the arguments after the word
Key Function.
-
If the thread does not receive no value, the
empty parenthesis or omit, ending the first line with the
name of the subprocess.
In addition, the keywords Por Valor
or Por Referencia
may optionally be added to indicate the type of passage in each argument. If not indicated, the arrays are passed by reference, the other expressions by value.
-
The passage by reference implies that if the function modifies the
argument, the variable that was used in the
call.
-
The Value Pass implies that the function operates with a copy of
the variable (or the result of the expression) that was used in the
call, so that the modifications applied by the function are not
will be reflected outside of it.
To invoke the function you must use its name and in parentheses the parameters.
// Funcion que no recibe argumentos ni devuelve nada
Funcion Saludar
Escribir "Hola mundo!"
FinFuncion
// Funcion que recibe el argumento nombre, y devuelve el saludo
Funcion respuesta <- SaludarA(nombre)
respuesta <- "Hola " + nombre
FinFuncion
// Proceso principal, que invoca a las funciones antes declaradas
Algoritmo PruebaFunciones
// Llamada a la funcion Saludar
// Como no recibe argumentos pueden omitirse los paréntesis vacios
Saludar
// Llamada a la función SaludarA()
Escribir "Ingrese el nombre de la persona:"
Leer nombrePersona
Escribir SaludarA(nombre)
FinAlgoritmo
The documentation on the pseudocode is found in the option Ayuda > Indice
of the navigation bar or by the keyboard shortcut F1
.