' PROGRAMACION MODULAR
DECLARE SUB PorReferencia(c as integer)
DECLARE SUB PorCopia(c as integer)
DECLARE SUB NoRetornaNada(a as integer, b as integer)
DECLARE FUNCTION FuncionDoble (b as integer)
DECLARE SUB RecibeVector ( v(1 TO 10) as integer)
DECLARE SUB ReceivesMatrix ( m( 1 TO 3 , 1 TO 4) as integer)
PRINT FuncionDoble(5) ' Escribir FuncionDoble(5);
CALL NoRetornaNada(3, 9) ' Llamado a un procedimeiento se requiere de CALL // imprime dentro del procedimiento
DIM c AS INTEGER
c = 0 ' c<-0;
CALL PorReferencia(c) ' PorReferencia(c);
PRINT c 'Escribir c;
c = 0 ' c<-0;
CALL PorCopia(c) ' PorCopia(c);
PRINT c 'Escribir c;
DIM a(1 TO 10) as integer, b(1 TO 3, 1 TO 4) as integer' en base uno ' Dimension a[10],b[3,4];
CALL RecibeVector( a() ) ´ Se requeire llamar el nombre de la variable con parentesis vacios
CALL RecibeMatriz( b() )
'FinProceso
FUNCTION FuncionDoble (b as integer) ' Funcion a<-FuncionDoble(b por copia)
b_copia = b ' truco para hacer una variable por copia por que por defecto en QBASIC son por referencia
FuncionDoble = 2 * b_copia ' a=2*b; // OJO: se requiere que la variable de salida de PSEINT se renombre con el mismo nombre de la funcion
END FUNCTION ' FinFuncion
SUB NoRetornaNada (a as integer, b as integer) ' SubProceso NoRetornaNada(a,b)
a_copia = a ' truco para hacer una variable por copia por que por defecto en QBASIC son por referencia
b_copia = b
PRINT a_copia + b_copia ' escribir a+b;
END SUB ' FinSubProceso
SUB PorReferencia (b as integer) ' SubProceso PorReferencia(b por referencia)
b = 7
END SUB ' FinSubProceso
SUB PorCopia (c as integer) ' SubProceso PorCopia(c por copia)
c_copia = c ' truco para hacer una variable por copia
c_copia = 7
END SUB ' FinSubProceso
SUB RecibeVector (v( 1 TO 10) as integer) ' SubProceso RecibeVector(v)
INPUT "v(1)=", v(1) ' Leer v[1];
PRINT "v(1)="; v(1)
END SUB ' FinSubProceso
SUB RecibeMatriz (m( 1 TO 3 , 1 TO 4) as integer) ' SubProceso RecibeMatriz(m)
INPUT "m(1,1)=", m(1, 1) ' Leer m[1,1];
END SUB ' FinSubProceso