You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Concepts/dt_pointer.md
+51-11Lines changed: 51 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,13 @@ $MyVar:="Hello"
33
33
$MyVar is now a variable containing the string “Hello.” We can now create a pointer to $MyVar:
34
34
35
35
```4d
36
-
C_POINTER($MyPointer)
36
+
var $MyPointer : Pointer
37
37
$MyPointer:=->$MyVar
38
38
```
39
39
The -> symbol means “get a pointer to.” This symbol is formed by a dash followed by a “greater than” sign. In this case, it gets the pointer that references or “points to” $MyVar. This pointer is assigned to MyPointer with the assignment operator.
40
40
41
41
$MyPointer is now a variable that contains a pointer to $MyVar. $MyPointer does not contain “Hello”, which is the value in $MyVar, but you can use $MyPointer to get this value. The following expression returns the value in $MyVar:
Trying to assign or to read a null pointer (aka "nil") will produce an error at runtime. For example:
92
+
93
+
```4d
94
+
var $p : Pointer // non initialized pointer (Nil value)
95
+
$v:=$p-> // error
96
+
$p->:=$v // error
97
+
```
98
+
99
+
To prevent such errors, you can write:
100
+
101
+
```4d
102
+
If ($p#Null)
103
+
$p->:=$v
104
+
End if
105
+
```
106
+
107
+
:::
108
+
109
+
110
+
111
+
87
112
## Main usages
113
+
114
+
88
115
### Pointers to tables
116
+
89
117
Anywhere that the language expects to see a table, you can use a dereferenced pointer to the table. You create a pointer to a table by using a line like this:
90
118
```4d
91
119
$TablePtr:=->[anyTable]
@@ -118,19 +146,26 @@ OBJECT SET FONT($FieldPtr->;"Arial")
118
146
119
147
When you use pointers to process or local variables, you must be sure that the variable pointed to is already set when the pointer is used. Keep in mind that local variables are deleted when the method that created them has completed its execution and process variables are deleted at the end of the process that created them. When a pointer calls a variable that no longer exists, this causes a syntax error in interpreted mode (variable not defined) but it can generate a more serious error in compiled mode.
120
148
121
-
Pointers to local variables allow you to save process variables in many cases. Pointers to local variables can only be used within the same process. In the debugger, when you display a pointer to a local variable that has been declared in another method, the original method name is indicated in parentheses, after the pointer. For example, if you write in Method1:
149
+
Pointers to local variables allow you to save process variables in many cases. Pointers to local variables can only be used within the same process. In the debugger, when you display a pointer to a local variable that has been declared in another method, the original method name is indicated in parentheses, after the pointer. For example, if you write in *Method1*:
150
+
122
151
```4d
123
152
$MyVar:="Hello world"
124
153
Method2(->$MyVar)
125
154
```
126
-
In Method2, the debugger will display $1 as follows:
155
+
*Method2*:
127
156
128
-
|$1|->$MyVar (Method1)
129
-
|---|---
157
+
```4d
158
+
#DECLARE($param : Pointer)
159
+
...
160
+
```
161
+
The debugger will display $param as follows:
130
162
131
-
The value of $1 will be:
163
+
|$param|->$MyVar (Method1)|
164
+
|---|---|
165
+
166
+
You can expand $param and its value will be:
132
167
133
-
|$MyVar (Method1)|"Hello world"|
168
+
|$MyVar|"Hello world"|
134
169
|---|---|
135
170
136
171
### Pointers to array elements
@@ -162,12 +197,14 @@ If you need to refer to the fourth element in the array by using the pointer, yo
162
197
163
198
### Pointers as parameters to methods
164
199
You can pass a pointer as a parameter to a method. Inside the method, you can modify the object referenced by the pointer. For example, the following method, `takeTwo`, takes two parameters that are pointers. It changes the object referenced by the first parameter to uppercase characters, and the object referenced by the second parameter to lowercase characters. Here is the project method:
200
+
165
201
```4d
166
202
//takeTwo project method
167
-
//$1 – Pointer to a string field or variable. Change this to uppercase.
168
-
//$2 – Pointer to a string field or variable. Change this to lowercase.
169
-
$1->:=Uppercase($1->)
170
-
$2->:=Lowercase($2->)
203
+
//$changeUp – Pointer to a string field or variable. Change this to uppercase.
204
+
//$changeLow – Pointer to a string field or variable. Change this to lowercase.
The following line uses the `takeTwo` method to change a field to uppercase characters and to change a variable to lowercase characters:
@@ -180,6 +217,7 @@ If the field [myTable]myField contained the string "jones", it would be changed
180
217
In the takeTwo method, and in fact, whenever you use pointers, it is important that the data type of the object being referenced is correct. In the previous example, the pointers must point to something that contains a string or text.
181
218
182
219
### Pointers to pointers
220
+
183
221
If you really like to complicate things, you can use pointers to reference other pointers. Consider this example:
Copy file name to clipboardExpand all lines: docs/Debugging/debugLogFiles.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ id: debugLogFiles
3
3
title: Log files
4
4
---
5
5
6
-
4D applications can generate several log files that are useful for debugging or optimizing their execution. Logs are usually started or stopped using selectors of the [SET DATABASE PARAMETER](https://doc.4d.com/4dv20/help/command/en/page642.html), [WEB SET OPTION](https://doc.4d.com/4dv20/help/command/en/page1210.html), or [HTTP SET OPTION](https://doc.4d.com/4dv20/help/command/en/page1160.html) commands and are stored in the [Logs folder](Project/architecture.md#logs) of the project.
6
+
4D applications can generate several log files that are useful for debugging or optimizing their execution. Logs are usually started or stopped using selectors of the [SET DATABASE PARAMETER](../commands-legacy/set-database-parameter.md), [WEB SET OPTION](../commands-legacy/web-set-option.md), or [HTTP SET OPTION](../commands-legacy/http-set-option.md) commands and are stored in the [Logs folder](Project/architecture.md#logs) of the project.
7
7
8
8
Information logged needs to be analyzed to detect and fix issues. This section provides a comprehensive description of the following log files:
9
9
@@ -290,7 +290,7 @@ These log files record each exchange between the 4D application and the mail ser
290
290
291
291
* SMTP - [SMTP New transporter](../commands/smtp-new-transporter.md)
292
292
* POP3 - [POP3 New transporter](../commands/pop3-new-transporter.md)
293
-
* IMAP - [IMAP New transporter](../commands/imap-new-transporter.mdnsporter)
293
+
* IMAP - [IMAP New transporter](../commands/imap-new-transporter.md)
Copy file name to clipboardExpand all lines: docs/FormEditor/forms.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ You can create multiple pages for an input form. If you have more fields or vari
88
88
89
89
- Place the most important information on the first page and less important information on other pages.
90
90
- Organize each topic on its own page.
91
-
- Reduce or eliminate scrolling during data entry by setting the [entry order](../FormEditor/formEditor.html#data-entry-order).
91
+
- Reduce or eliminate scrolling during data entry by setting the [entry order](formEditor.md#data-entry-order).
92
92
- Provide space around the form elements for an attractive screen design.
93
93
94
94
Multiple pages are a convenience used for input forms only. They are not for printed output. When a multi-page form is printed, only the first page is printed.
@@ -112,7 +112,7 @@ When a form is executed, the objects are loaded and combined in the following or
112
112
3. Page zero of the open form
113
113
4. Current page of the open form.
114
114
115
-
This order determines the default [entry order](../FormEditor/formEditor.html#data-entry-order) of objects in the form.
115
+
This order determines the default [entry order](formEditor.md#data-entry-order) of objects in the form.
116
116
117
117
> Only pages 0 and 1 of an inherited form can appear in other forms.
Copy file name to clipboardExpand all lines: docs/FormObjects/dropdownList_Overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ You can create different types of drop-down lists with different features. To de
28
28
29
29
> This feature is only available in 4D projects.
30
30
31
-
An [object](Concepts/dt_object.md) encapsulating a [collection](Concepts/dt_collection) can be used as the data source of a drop-down list. The object must contain the following properties:
31
+
An [object](Concepts/dt_object.md) encapsulating a [collection](Concepts/dt_collection.md) can be used as the data source of a drop-down list. The object must contain the following properties:
0 commit comments