PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Open Window with Parameter BY REFERENCE!
Open Window with Parameter BY REFERENCE!
Iniciado por meikl, 15,mar. 2016 11:49 - 5 respuestas
Miembro registrado
127 mensajes
Publicado el 15,marzo 2016 - 11:49
How to do?
Miembro registrado
102 mensajes
Publicado el 16,marzo 2016 - 11:08
Meikl,

as stated in the docs http://doc.windev.com/en-US/…

a parameter of a window is ' passed by address'.

So you have to do this by yourself. One possibility is to create a global variable in the project code (you can't do this in the window that is calling the other window). In the other window you can work with that global variable.

Another possibility is to use a passed variable in the called window and then put the result in CalledWindow..ReturnedValue before you Close() the window. Then you call your window like this:

value = Open( WIN_CalledWindow, value )


And in WIN_CalledWindow it is something like

Procedure WIN_CalledWindow( value )
value = value + 10
MyWindow..ReturnedValue = value
Close()


You could also change any item of the calling window like this:

Procedure WIN_CalledWindow( value )
value = value + 10
WIN_Main.STC_whatever = value


HTH
Sebastian

--
http://arnoldconsult.de
WinDev 20 with Oracle, WinDevMobile Android Apps and Motorola Windows CE Mobile Barcode Scanners, Python 3 with Oracle and MySQL
Miembro registrado
28 mensajes
Publicado el 16,marzo 2016 - 13:02
Please excuse my ignorance but I had assumed that passing variables by REFERENCE, and ADDRESS were effectively the same thing. Windev talks about passing variables by ADDRESS and by VALUE. The only effective difference being that the parameter variable in the calling program remains unmodified when passed by value, after the called procedure is run.
Miembro registrado
102 mensajes
Publicado el 16,marzo 2016 - 15:39
Dave,

I'm with you. But after reading a little further I'm confused by myself.

In the notes of http://doc.windev.com/en-US/…
you can read

"If the parameters passed to a window are modified in this window, these modifications will be taken into account in this window only. The value of these parameters is not modified in the calling process."

In my first answer I did a quick check before with calling a new test window with one parameter. When I changed the value inside the new window it wasn't changed in the calling window. That's why I wrote how to handle this instead with return values.

BUT: According to the docs of my first link the docs say:

"<Parameter 1>: Type of the value sent to the window (optional)
First parameter that must be passed to the "Declaration of global variables" process of the window to open. This parameter is passed by address and it is considered as being a global variable of the window."

So right now I can only say that even if the docs say that parameters to windows are passed by address/reference they are not.

--
http://arnoldconsult.de
WinDev 20 with Oracle, WinDevMobile Android Apps and Motorola Windows CE Mobile Barcode Scanners, Python 3 with Oracle and MySQL
Mensaje modificado, 16,marzo 2016 - 15:42
Miembro registrado
28 mensajes
Publicado el 17,marzo 2016 - 05:11
Thanks Sebastian.
Miembro registrado
127 mensajes
Publicado el 17,marzo 2016 - 14:40
Thanks Sebastian.

will try the ..returnedValue property

Currently i use a public local procedure (as getter) in the window on behalf for forwarding the result-structure to the caller.
Must called by the Caller before close.

regards Meikl ;)