Pasar variables de una aplicación a otra - Forum

Forum Navigation
You need to log in to create posts and topics.

Pasar variables de una aplicación a otra

Escenario. El proyecto que desarrollo tiene tres aplicaciones: Inicio, Profesor y  Alumno

Esto implica tres archivos .exe: inicio.exe, profesor.exe y alumno.exe.

La primera aplicación (inicio.exe)
pide al usuario que se identifique como profesor o alumno
pide un nombre y una contraseña
comprueba el registro del usuario
si procede, lo da de alta,
y carga la aplicación correspondiente:  o bien profesor.exe o bien alumno.exe

Todo esto ya funciona, gracias al comando RUN:
Run "[PubDir]profesor.exe" "" "Normal" "" "" o bien Run "[PubDir]alumno.exe" "" "Normal" "" ""

Problemas. A partir de aquí, tengo dos problemas:

1) Quisiera que, al cargar la aplicación PROFESOR o la aplicación ALUMNO,
se cerrara completamente la aplicaciób INICIO,
de manera que no ocupara memoria alguna.
No sé cómo hacerlo.

2) Tanto al cargar PROFESOR como al cargar ALUMNO,
quisiera mantener dos variables: [NumOrden] y [Nombre],
obtenidas las dos en la aplicación INICIO.
Esta es la sintaxis del comando "Run":
Run "command" "parameters" "options" "subroutine" "variable"
No he encontrado ningún ejemplo del uso de "parameters".
He probado, sin éxito,  Run "[PubDir]profesor.exe" "[Nombre]" "Normal" "" ""
No sé cómo hacerlo.
Si podéis ayudarme...
:)

@joandetarragona

It is usually easier to make one application than three. For example, after authorizing a user, you can direct him to the desired page of the application and not show others.

But if you need to close the Start application after it has called another application, you can start the required application and then execute the Exit command. Those. the application will close itself after starting another one.

There is another way. You can close an application from another application with the CloseApp command, or with plugins:

rtFileSystemMgt 1.4.3b (Ron Marie Services)
rtCloseWinApplication

dec_Plus 1.9 (David Esperalta)
dec_CerrarAplicacion_1
dec_CerrarAplicacion_2

You can save variables (names and values) to a text file (with the SaveVariables command) and read from it (with the LoadVariables command) using any of your programs.

@vadim

Gracias por contestar.

Todavia no sé nada de plugins.

Había pensado eso del "text file", que es lo que usaba en los años 70, con el GWBASIC,
pero  se me ocurrió que podría haber otra solución con los "parameters" del comando RUN.

Estudiaré lo que me dices. :)

@joandetarragona

I have not tried passing variable values ​​using the Run command.

There are several advantages to saving values ​​to a file:
Your Start program can be closed, its variables are deleted from memory, but what it wrote to the file will remain in the file and can be read at any time by another application that knows the name of this file.

In addition to the methods already suggested for saving the values ​​of variables, you can use the usual commands for writing to a file (FileWrite) and reading from a file (FileRead). For example, you can write the value [OrderNum] in the first line, and the value [Name] in the second line. The program that will read the lines will know what is written on which line by the line number.

If you do not want to create a text file in plain sight, then you can create it in the Windows folder for temporary files (the [TempDir] variable stores the path to this folder) or store the data in the registry (commands: RegistryWrite and RegistryRead). And even encrypted, if required.

If you use a database (for example, to check authorization), then you can store data in it, in a separate table or in separate fields.

There are always more than one ways. You can choose the most suitable one for your project.

Atención a esta variable
[CommandLine]
Parámetros de línea de comandos pasados a la publicación. Si hay varios parámetros, están separados con retornos de carro [#13].
Si ejecutas Run "[PubDir]profesor.exe" "[Nombre]" "Normal" "" "" puedes en las propiedades del libro -- acciones leer [Commandline] que contendra [Nombre] y en consecuencia decidir que hacer.
Espero te sea de ayuda
salu2

 

Attention to this variable
[CommandLine]
Command line parameters passed to publication. If there are multiple parameters, they are separated with carriage returns [# 13].
If you execute Run "[PubDir] teacher.exe" "[Name]" "Normal" "" "" you can in the properties of the book - actions read [Commandline] that [Name] will contain and consequently decide what to do.
I hope it helps
salu2

Vadim has reacted to this post.
Vadim