In PowerBuilder OpenWithParm, ClosewithRet, OpenSheetwithParm, Windown, WINDOWNAME.OpenUserObjectWithParm, etc., all of which stores the parameter Parameter or ReturnValue that stores the Message message object when the window operation (open or off) is performed.
Message object messages have three properties to store data that these functions passed to the window (depending on the type of parameter to the window operation). According to the parameter data type according to the Parameter / ReturnValue parameter data, the value of this parameter saves the different properties of the Message object. The corresponding relationship between the type of Parameter / ReturnValue parameter and the Message object properties used are as follows:
Parameter Type Message Object Properties
Numeric (numeric) message.doubleparm
PowerObject (PB object, including user-defined structural data type) Message.PowerObjectParm
String (string) message.stringparm
The application extracts the function from the different properties of the Message message object according to the parameter type of the OpenWithParm () and other functions, and transmits the value to the opened window.
If it is transmitted in the PB, it is easy to implement. In the call script, you can use the following code:
OpenwithParm (w_wantparm, parmtotrans)
Then Type in the OPEN event on the open window W_wantparm:
String ls_getparm
ls_getparm = message.stringparm
...
If you need to pass multiple parameters, you can use the following two methods:
method one
Define structural variables: lstr_declaredstr, which contains the various parameters you want to pass:
Variable name variable type
ID unsignedlong
Name Character
Email Character
Homepage Character
...
In the call script, use the following code:
LSTR_DECLAREDSTR LSTR-PARMTOTRANS
LSTR-PARMTORANS.ID = 1
Lstr-paramtotrans.name = "Panya"
Lstr-Paramtotrans.Email = "Panya@163.net"
LSTR-paramtotrans.homepage = "http://panya.163.net"
...
OpenwithParm (w_wantparm, parmtotrans)
Next, get the structure information in the open event of the window W-Wantparm:
LSTR-DECLAREDSTR LSTR-GETPARM
Integer Li_GetID
String ls_getname
String ls_getemail
String ls_gethomepage
LSTR_GETPARM = Message.PowerObjectParm
li_getid = lstr_getparm.id
LS_GETNAME = lstr_getparm.name
Ls_geemail = lstr_getparm.email
Ls_gethomepage = lstr_getparm.homepage
...
Among them
String email
String homepage
...
Open the window W- WantParm and pass multiple parameters:
U_n_parmtostore lnv_paramtotranslnv_paramtotrans.id = 1
LNV_Paramtotrans.name = "Panya"
LNV_Paramtotrans.Email = "Panya@163.net"
LNV_Paramtotrans.homePage = "http://pbnet.126.com"
...
OpenWithParm (w_wantparm, lnv_paramtotrans)
Parameters sent in the W_WANTPARM's Open events:
U_n_parmtostore lnv_getparam
Integer Li_GetID
String ls_getname
String ls_getemail
String ls_gethomepage
LNV_GETPARAM = Message.PowerObjectParm
li_getid = lnv_getparam.id
Ls_getname = lnv_getparam.name
Ls_gethomepage = lnv_getparam.homepage
LS_GETEMAIL = LNV_GETPARAM.EMAIL
...
In the above two methods, the first method is more simple and practical, but if you encounter more complex data, it cannot be fully described in a structural data; the second method is not only convenient and flexible, but also can transmit complex The data. Of course, the transmission of the parameter is not only more than the above method, you can also use global variables or public accessible window instance variables to transfer parameters, or call a function in the window, and pass the required parameters, this is not Take later.