Several uses of parameter passing.

Source: Internet
Author: User

Several uses of parameter passing.

Once you need to pass parameters between several windows, the first thing to think about is defining a global variable.

Can be done after the discovery is not very ideal.

Finally to others to learn the parameters of transmission, solve a lot of problems, it is not easy to make mistakes.

Now write it to share with you, and keep it for yourself so that you can see it.
-----------------------------------------------------------
Let's explain the function meaning of parameter passing:
Message.stringparm (the character is passed)
Message. Doubleparm (Numeric)
Message. Powerobjectparm (Can be a window, object, structure, etc.)
Example: (for example, a numeric pass)
Write the following code in the related event in the W_old window to send the parameters to be passed:
Long Ll_old
Ll_old = The value you want to pass
Openwithparm (w_new (/New window), Ll_old)
------------
Write the following code in the related event in the W_new window (new window) to accept the parameter:
Long ll_new
Ll_new = message.doubleparm/* So you receive the parameters you want. */
-----------------------------------------------------------

The above is just a passing argument,
For multiple-parameter transmission, there are 3 ways:
1. Pass the word Fu group to the destination for segmentation
2. Transfer Structure objects
3. Use the object to do the carrier transmission
I now master the first two, the last one I do not understand. It will be replenished later.

Now first: 1. Pass the word Fu group to the destination to split
In other words, combining multiple parameters into one to pass,
The combination of the need to add a delimiter---their own definition. After the parameter is received, it is split into multiple.
* Write the following code in related events in the W_old window:
/* For example, the combination of a good string for pass_old= "123|4567"---attention to the combination of the first 123 and 4567
It may all be long, it doesn't matter, the conversion type is OK.
String Pass_old
Pass_old =string (ll_pre) + "|" + String (Ll_tra)
Ll_pre = 123,ll_tra = 4567
Openwithparm (w_new (/New window), Pass_old)
----------
* Write the following code in the related events in the W_new window (new window):
Integer Li_fen/* Defines the location where the separator is to be recorded/*
Long Ll_newpre,ll_newtra/* is used to store two parts separately * *
String pass_new
Pass_new = Message.stringparm

Li_fen=pos (pass_new, "|") /* Identify and record the location of the separator

Ll_newpre=long (Left (pass_new,li_fen-1))

Ll_newtra=long (Right (Pass_new,len (pass_new)-Li_fen))

/* Above is the first method-----Use the word Fu group transmission, to the destination for segmentation * *
--------------------------------------
In terms of saying: 2. Passing Structure objects
Create a Structure object in the library file, note that it is created, because it is like a window
is an object, not defined with a sentence. Structure S_info
Variable name variable type
ID Long
Name Char
Sex Char
/* Take this as an example first. */
* * Write the following code in the related event in the W_old window:
S_info Lstr_pre
Lstr_pre.id = 1/* Value of assignment ID
Lstr_pre.name = "Zhdleo"/* Value of assignment name
Lstr_pre.name = "Male"/* Assign sex value
Openwithparm (w_new (/New window), Lstr_pre)
* * Write the following code in the related event in the W_new window (new window):
S_info Lstr_tra
Long tra_id
String Tra_name
String Tra_sex/* Defines the variables to receive

Lstr_tra = message. Powerobjectparm/* Receive parameters
tra_id = Lstr_tra.id
tra_id = Lstr_tra.name
tra_id = lstr_tra.sex/* Assignment

/* Above is the second method------passing struct objects
-------------------------------------------
I personally think that the second method is very good, not only the structure is clear, but also defines the structure
Can see, easy to understand.

As for the third kind, I still need to study it slowly.

If someone has a good idea, or a third one, or a better way,
Please e-mail:zhdleo@163.com


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.