4D v14ビデオの内容 |
||
|
4D v14
ビデオの内容
ビデオの内容
In this video, we're going to learn how to call methods and use parameters. We'll cover pointer type parameters later on. The purpose of generic programming is to optimize development and to facilitate maintenance and portability. We've already used a simple call to a method (without parameters) in the "On Startup" database method where we called the NAVIGATION method. In the first programming lessons, we saw how to configure buttons according to the page selected in the navigation form. Now we're going to optimize this programming so as to keep only one method that is used for all the navigation buttons (All, Query, Order by, and so on).
It will receive 2 parameters:
We call this method as follows: In a button, we will call NAVIGATION_FUNCTIONS
NAVIGATION_FUNCTIONS("All";FORM Get current page) There are two ways to type the parameters of the method that is called, in other words, the NAVIGATION_FUNCTIONS method: You'll notice that to name parameters, we use the syntax $1, $2, ... $n to retrieve each parameter. To make your method easy to read, we suggest that you create local variables with explicit names where you assign the value of the parameters received. So it is better to write: C_TEXT($1;$Action) since we can declare several variables in a compiler directive of the C_TEXT type for simple variables. C_LONGINT($2;$PageNum) and to retrieve the value of $1 in $Action and the value of $2 in $PageNumber, you can just write: $Action:=$1 The rest of the method is an adaptation of what we already described in previous sections; namely, adjusting the action to the request and configuring it according to the page and thus the table chosen: We will use:
:($Action="All")
What about the information we need to replace?
When we cover pointers, then we'll replace what we have here with a more generic method. We can do the same thing with the Query button.
and, as we did before, replace FORM Get current page by the variable that we received. We're going to put a break point and check that we go to this method when the form is executed. If we click on "All", we see the method being executed but what we're specifically interested in is the stacking of the methods:
If we double-click on this method, the code appears that leads us to this point and we can see that the NAVIGATIONS_FUNCTIONS method was called (with the parameters: "All", FORM Get current page). The method was received. Here it received the parameters: $1 = "All", $2 = the page number--here it is page 1. Next, $Action is "All" so we're supposed to go to this part We will then:
We can see that our method works correctly. |
プロパティ
プロダクト: 4D ARTICLE USAGE
セルフトレーニング ( 4D v13) |