Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2091 commits
Select commit Hold shift + click to select a range
e8a7c48
New translations tabcontrol.md (Spanish)
arnaud4d Apr 14, 2026
f784c9e
New translations viewproarea_overview.md (Spanish)
arnaud4d Apr 14, 2026
476cb0d
New translations webarea_overview.md (Spanish)
arnaud4d Apr 14, 2026
57516f7
New translations writeproarea_overview.md (Spanish)
arnaud4d Apr 14, 2026
a48541c
New translations users.md (Spanish)
arnaud4d Apr 14, 2026
92a728f
New translations user-new.md (Spanish)
arnaud4d Apr 14, 2026
4a7740b
New translations filehandleclass.md (Spanish)
arnaud4d Apr 14, 2026
fdf0c9a
New translations listbox_overview.md (Spanish)
arnaud4d Apr 14, 2026
af2f577
New translations users.md (Spanish)
arnaud4d Apr 14, 2026
033e653
New translations interface.md (Spanish)
arnaud4d Apr 14, 2026
c68f3ca
New translations async.md (Spanish)
arnaud4d Apr 14, 2026
4c94241
New translations listbox-object.md (Spanish)
arnaud4d Apr 14, 2026
2262784
New translations listbox-column.md (Spanish)
arnaud4d Apr 14, 2026
55d947b
New translations listbox-header-footer.md (Spanish)
arnaud4d Apr 14, 2026
53085a0
New translations listbox-column.md (Spanish)
arnaud4d Apr 14, 2026
3fc68e9
New translations listbox-header-footer.md (Spanish)
arnaud4d Apr 14, 2026
db6ec4d
New translations listbox-object.md (Spanish)
arnaud4d Apr 14, 2026
55607fe
New translations listbox-object.md (Spanish)
arnaud4d Apr 14, 2026
5feca66
New translations formulaclass.md (Spanish)
arnaud4d Apr 14, 2026
5e33664
New translations wp-new-style-sheet.md (Spanish)
arnaud4d Apr 14, 2026
e763753
New translations wp-delete-style-sheet.md (Spanish)
arnaud4d Apr 14, 2026
6b124c7
New translations wp-get-style-sheet.md (Spanish)
arnaud4d Apr 14, 2026
a328a0b
New translations ordering.md (Spanish)
arnaud4d Apr 14, 2026
2066fea
New translations async.md (Spanish)
arnaud4d Apr 14, 2026
5992bec
New translations async.md (Spanish)
arnaud4d Apr 14, 2026
2254074
New translations command-index.md (Japanese)
arnaud4d Apr 14, 2026
95fcea3
New translations user-new.md (Japanese)
arnaud4d Apr 14, 2026
ec74e12
New translations wp-new-style-sheet.md (Japanese)
arnaud4d Apr 14, 2026
e519ebd
New translations wp-delete-style-sheet.md (Japanese)
arnaud4d Apr 14, 2026
24f6ef8
New translations wp-get-style-sheet.md (Japanese)
arnaud4d Apr 14, 2026
7c3a5b9
New translations command-index.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
daec12b
New translations user-new.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
2a4b33c
New translations wp-new-style-sheet.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
e826e0f
New translations wp-delete-style-sheet.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
c015f07
New translations wp-get-style-sheet.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
1464b7d
New translations imapnotifier.md (Spanish)
arnaud4d Apr 14, 2026
d442cfc
Feature/server execution (#3261)
arnaud4d Apr 14, 2026
a5f1f6b
New translations wp-import-style-sheets.md (French)
arnaud4d Apr 14, 2026
4619ea6
New translations wp-import-style-sheets.md (Spanish)
arnaud4d Apr 14, 2026
00bf2a8
New translations wp-import-style-sheets.md (Japanese)
arnaud4d Apr 14, 2026
f9e65cc
New translations wp-import-style-sheets.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
824d582
New translations entityselectionclass.md (Spanish)
arnaud4d Apr 14, 2026
ffaf8a2
New translations fileclass.md (Spanish)
arnaud4d Apr 14, 2026
82e957b
New translations folderclass.md (Spanish)
arnaud4d Apr 14, 2026
001ddbf
New translations properties_listbox.md (Spanish)
arnaud4d Apr 14, 2026
6354689
New translations properties_object.md (Spanish)
arnaud4d Apr 14, 2026
42fca15
New translations properties_resizingoptions.md (Spanish)
arnaud4d Apr 14, 2026
e4bff8e
New translations properties_textandpicture.md (Spanish)
arnaud4d Apr 14, 2026
c813871
New translations current.json (Japanese)
arnaud4d Apr 14, 2026
fc0680e
New translations blobclass.md (Spanish)
arnaud4d Apr 14, 2026
d1e3944
New translations collectionclass.md (Spanish)
arnaud4d Apr 14, 2026
3bfeba9
New translations entityclass.md (Spanish)
arnaud4d Apr 14, 2026
dddad08
New translations entityselectionclass.md (Spanish)
arnaud4d Apr 14, 2026
ef44d53
New translations fileclass.md (Spanish)
arnaud4d Apr 14, 2026
bc685b5
New translations folderclass.md (Spanish)
arnaud4d Apr 14, 2026
af50b90
New translations cli.md (Spanish)
arnaud4d Apr 14, 2026
eb28aa9
New translations properties_listbox.md (Spanish)
arnaud4d Apr 14, 2026
9bbda9a
New translations properties_object.md (Spanish)
arnaud4d Apr 14, 2026
2ed805f
New translations properties_resizingoptions.md (Spanish)
arnaud4d Apr 14, 2026
a8bf8ef
New translations properties_textandpicture.md (Spanish)
arnaud4d Apr 14, 2026
2838a85
New translations blobclass.md (French)
arnaud4d Apr 14, 2026
85b0f2b
New translations collectionclass.md (French)
arnaud4d Apr 14, 2026
ebb6441
New translations emailobjectclass.md (French)
arnaud4d Apr 14, 2026
4e9942c
New translations fileclass.md (French)
arnaud4d Apr 14, 2026
fc18cea
New translations blobclass.md (Spanish)
arnaud4d Apr 14, 2026
c7965d1
New translations collectionclass.md (Spanish)
arnaud4d Apr 14, 2026
0bbcb95
New translations emailobjectclass.md (Spanish)
arnaud4d Apr 14, 2026
ebad8d2
New translations fileclass.md (Spanish)
arnaud4d Apr 14, 2026
46cacaf
New translations blobclass.md (Japanese)
arnaud4d Apr 14, 2026
755c906
New translations collectionclass.md (Japanese)
arnaud4d Apr 14, 2026
019575e
New translations emailobjectclass.md (Japanese)
arnaud4d Apr 14, 2026
1f04491
New translations fileclass.md (Japanese)
arnaud4d Apr 14, 2026
69b6ffc
New translations blobclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
2bb8995
New translations collectionclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
35d7496
New translations emailobjectclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
9d08451
New translations fileclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
548f76e
New translations folderclass.md (French)
arnaud4d Apr 14, 2026
237952d
New translations mailattachmentclass.md (French)
arnaud4d Apr 14, 2026
935558a
New translations sessionclass.md (French)
arnaud4d Apr 14, 2026
29f9106
New translations folderclass.md (Spanish)
arnaud4d Apr 14, 2026
421cc83
New translations mailattachmentclass.md (Spanish)
arnaud4d Apr 14, 2026
eedb569
New translations sessionclass.md (Spanish)
arnaud4d Apr 14, 2026
aa7660b
New translations folderclass.md (Japanese)
arnaud4d Apr 14, 2026
661f98c
New translations mailattachmentclass.md (Japanese)
arnaud4d Apr 14, 2026
92b7cd8
New translations sessionclass.md (Japanese)
arnaud4d Apr 14, 2026
3d1ce0f
New translations folderclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
4b9f506
New translations mailattachmentclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
1a173df
New translations sessionclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
34496a2
New translations webserverclass.md (French)
arnaud4d Apr 14, 2026
355cc1b
New translations webserverclass.md (Spanish)
arnaud4d Apr 14, 2026
7f4b3a9
New translations webserverclass.md (Japanese)
arnaud4d Apr 14, 2026
75dd6be
New translations webserverclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
5d61534
New translations classes.md (French)
arnaud4d Apr 14, 2026
325169f
New translations classes.md (Spanish)
arnaud4d Apr 14, 2026
57640d2
New translations classes.md (Japanese)
arnaud4d Apr 14, 2026
30d54f6
New translations classes.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
df0e11f
New translations dt_object.md (French)
arnaud4d Apr 14, 2026
7b7145c
New translations dt_object.md (Spanish)
arnaud4d Apr 14, 2026
bca5b00
New translations dt_object.md (Japanese)
arnaud4d Apr 14, 2026
8ee4ec4
New translations dt_object.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
504664e
New translations quick-tour.md (Spanish)
arnaud4d Apr 14, 2026
8120bc3
New translations clientserver.md (French)
arnaud4d Apr 14, 2026
e580baa
New translations clientserver.md (Spanish)
arnaud4d Apr 14, 2026
581ac33
New translations clientserver.md (Japanese)
arnaud4d Apr 14, 2026
147853d
New translations clientserver.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
159f9e2
New translations properties_object.md (Spanish)
arnaud4d Apr 14, 2026
7e7c2b1
New translations updates.md (French)
arnaud4d Apr 14, 2026
2e307ad
New translations client-server-optimization.md (French)
arnaud4d Apr 14, 2026
1dc9d35
New translations ordaclasses.md (French)
arnaud4d Apr 14, 2026
ad704fa
New translations updates.md (Spanish)
arnaud4d Apr 14, 2026
13bb50b
New translations client-server-optimization.md (Spanish)
arnaud4d Apr 14, 2026
c04a916
New translations ordaclasses.md (Spanish)
arnaud4d Apr 14, 2026
f6f6d33
New translations updates.md (Japanese)
arnaud4d Apr 14, 2026
4342bf9
New translations client-server-optimization.md (Japanese)
arnaud4d Apr 14, 2026
aee270a
New translations ordaclasses.md (Japanese)
arnaud4d Apr 14, 2026
e35b29f
New translations updates.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
bdc9b92
New translations client-server-optimization.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
7b10d79
New translations ordaclasses.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
8ab118f
New translations components.md (Spanish)
arnaud4d Apr 14, 2026
c999a15
New translations orda-events.md (French)
arnaud4d Apr 14, 2026
e83f964
New translations vectorclass.md (French)
arnaud4d Apr 14, 2026
50f49f6
New translations orda-events.md (Spanish)
arnaud4d Apr 14, 2026
f30a299
New translations vectorclass.md (Spanish)
arnaud4d Apr 14, 2026
b4bdbd5
New translations orda-events.md (Japanese)
arnaud4d Apr 14, 2026
77b32f8
New translations vectorclass.md (Japanese)
arnaud4d Apr 14, 2026
c395c8f
New translations orda-events.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
5995ce4
New translations vectorclass.md (Portuguese, Brazilian)
arnaud4d Apr 14, 2026
b55ef01
New translations collectionclass.md (Spanish)
arnaud4d Apr 15, 2026
f2054c4
New translations properties_object.md (Spanish)
arnaud4d Apr 15, 2026
a7a2a3b
New translations sessions.md (French)
arnaud4d Apr 15, 2026
c4f63b0
New translations sessions.md (Spanish)
arnaud4d Apr 15, 2026
b0ee01b
New translations sessions.md (Japanese)
arnaud4d Apr 15, 2026
a890f5a
New translations sessions.md (Portuguese, Brazilian)
arnaud4d Apr 15, 2026
da3f077
New translations collectionclass.md (Spanish)
arnaud4d Apr 15, 2026
e049aed
New translations properties_object.md (Spanish)
arnaud4d Apr 15, 2026
afe360c
New translations async.md (Spanish)
arnaud4d Apr 15, 2026
add48b2
New translations formulaclass.md (French)
arnaud4d Apr 15, 2026
c4eb4fc
New translations methodclass.md (French)
arnaud4d Apr 15, 2026
e438b4a
New translations formulaclass.md (Spanish)
arnaud4d Apr 15, 2026
84cf877
New translations methodclass.md (Spanish)
arnaud4d Apr 15, 2026
0990bf5
New translations formulaclass.md (Japanese)
arnaud4d Apr 15, 2026
b114fb3
New translations methodclass.md (Japanese)
arnaud4d Apr 15, 2026
c16ee83
New translations formulaclass.md (Portuguese, Brazilian)
arnaud4d Apr 15, 2026
97f0791
New translations methodclass.md (Portuguese, Brazilian)
arnaud4d Apr 15, 2026
b6cdeb0
New translations async.md (Spanish)
arnaud4d Apr 15, 2026
3cd41d3
New translations async.md (Spanish)
arnaud4d Apr 15, 2026
1a3b3a2
Merge branch 'l10n_main'
arnaud4d Apr 15, 2026
bb5928d
fix links
arnaud4d Apr 15, 2026
36253ee
New Crowdin updates (#3263)
arnaud4d Apr 15, 2026
4dd8606
small fixes (#3264)
arnaud4d Apr 15, 2026
6268385
New Crowdin updates (#3265)
arnaud4d Apr 16, 2026
1d9807b
Feature/ai kit alias (#3267)
arnaud4d Apr 16, 2026
e34d364
New Crowdin updates (#3266)
arnaud4d Apr 17, 2026
acbf50f
New Crowdin updates (#3268)
arnaud4d Apr 17, 2026
74cbe7e
Update updates.md (#3269)
arnaud4d Apr 17, 2026
01e1a6b
New Crowdin updates (#3270)
arnaud4d Apr 20, 2026
8cbb85b
fixes (#3271)
arnaud4d Apr 20, 2026
47c83bb
Fix/crypter fr (#3272)
arnaud4d Apr 20, 2026
947633f
Fix/crypter fr (#3273)
arnaud4d Apr 21, 2026
50cb68b
reported 21 21R2 (#3274)
arnaud4d Apr 21, 2026
44e5657
Merge branch 'main' into main
arnaud4d Apr 21, 2026
87ec734
Version 21-R3 created
arnaud4d Apr 21, 2026
9428108
Update Crowdin configuration file
arnaud4d Apr 22, 2026
f12a315
New Crowdin updates (#3276)
arnaud4d Apr 22, 2026
e9f88ae
fix version label
arnaud4d Apr 23, 2026
7a947d5
Merge branch 'main' into main
arnaud4d Apr 23, 2026
a9273af
New Crowdin updates (#3277)
arnaud4d Apr 23, 2026
49b0b2d
fix themes in home (#3278)
arnaud4d Apr 23, 2026
ace56c7
Fix/after 21 r3 (#3280)
arnaud4d Apr 24, 2026
6f0f2a9
New Crowdin updates (#3279)
arnaud4d Apr 24, 2026
f0be837
New Crowdin updates (#3281)
arnaud4d Apr 27, 2026
709ddfa
Update README.md
arnaud4d Apr 27, 2026
65377ec
fixes (#3282)
arnaud4d Apr 27, 2026
35bdbd5
fix(redirection): correct version iteration to include all versions
e-marchand Apr 28, 2026
ec89b6a
New Crowdin updates (#3283)
arnaud4d Apr 28, 2026
ce8fe5e
Merge branch 'main' of https://github.com/doc4d/docs into pr/575
arnaud4d Apr 28, 2026
f02f7ca
Merge branch '4d:main' into main
arnaud4d Apr 28, 2026
5810507
New Crowdin updates (#3284)
arnaud4d Apr 28, 2026
a4d0819
fix param name imap (#3286)
arnaud4d Apr 29, 2026
b7c21e1
Update README with conflict resolution steps
arnaud4d Apr 29, 2026
03bea81
Modify version matching loop to skip first version
e-marchand Apr 29, 2026
29f6108
Feature/form open explained (#3287)
arnaud4d Apr 29, 2026
f7657eb
New Crowdin updates (#3285)
arnaud4d Apr 30, 2026
184041e
Feature/print winui liquid (#3289)
arnaud4d Apr 30, 2026
2913e6d
ci: Add step to fix version-dropdown links in workflow
e-marchand May 1, 2026
352349f
ci: Fix action reference in workflow-build.yml
e-marchand May 1, 2026
160afa4
Update crowdin.yml
arnaud4d May 5, 2026
07861b9
New Crowdin updates (#3288)
arnaud4d May 5, 2026
e830b59
Update crowdin.yml
arnaud4d May 5, 2026
f5ac3df
Update Crowdin configuration file
arnaud4d May 5, 2026
3d8fe1b
Update updates.md
arnaud4d May 5, 2026
ddf29eb
Update crowdin.yml
arnaud4d May 6, 2026
82283e7
WritePro: fix links on some file moved to some legacy folders
e-marchand May 6, 2026
22ad45d
New Crowdin updates (#3290)
arnaud4d May 6, 2026
dbdd35f
swizzle the code that build the version menu to find other versions o…
e-marchand May 6, 2026
f5ac671
Document fix for version switch between 21.x and 21 R+
arnaud4d May 6, 2026
41c064d
added iframes (#3292)
arnaud4d May 6, 2026
1a1f715
New Crowdin updates (#3293)
arnaud4d May 7, 2026
97ccf6e
Update crowdin.yml
arnaud4d May 7, 2026
7a023d7
Merge branch 'main' into main
arnaud4d May 7, 2026
d177b38
Merge branch '4d:main' into main
arnaud4d May 7, 2026
7b914f0
Fix/add classtore class (#3294)
arnaud4d May 7, 2026
6124de8
fixes
arnaud4d May 7, 2026
e990436
Update Crowdin configuration file
arnaud4d May 7, 2026
81bc5ea
fixes links
arnaud4d May 7, 2026
f9e0214
New Crowdin updates (#3295)
arnaud4d May 11, 2026
97f4fe6
added see also + fix link to jmap spec (#3296)
arnaud4d May 11, 2026
50f117d
Fix/links imap (#3297)
arnaud4d May 11, 2026
547b59f
Merge branch '4d:main' into main
arnaud4d May 11, 2026
99b7216
added see also addflags
arnaud4d May 11, 2026
ec6cba4
updated screens
arnaud4d May 11, 2026
1ed79ca
print images
arnaud4d May 11, 2026
58e22e1
fixes in commands
arnaud4d May 11, 2026
c7f6b5c
fixed redraw syntax
arnaud4d May 11, 2026
6faa452
fix of the fix redraw
arnaud4d May 11, 2026
1300abe
fix(ACI0106344): add missing Variable in ACCUMULATE syntax
e-marchand May 13, 2026
ec7aedb
New Crowdin updates (#3298)
arnaud4d May 14, 2026
2d310af
New Crowdin updates (#3299)
arnaud4d May 15, 2026
38e5dd8
New Crowdin updates (#3300)
arnaud4d May 18, 2026
0a5ae7b
New Crowdin updates (#3302)
arnaud4d May 21, 2026
2fb8ec6
show message in version menu if page do not exist in previous version
e-marchand May 22, 2026
39dfa95
New Crowdin updates (#3303)
arnaud4d May 22, 2026
e2c062a
fix(syntax): make parameters optional for OBJECT Get pointer, Window …
e-marchand May 22, 2026
a0bea02
for menu version skip main page when checking if page available
e-marchand May 22, 2026
acf0a90
fixed legacy links
arnaud4d May 22, 2026
d0a1804
Update updates.md
arnaud4d May 22, 2026
6581817
New Crowdin updates (#3304)
arnaud4d May 25, 2026
d640140
version menu: change message and restore icon
e-marchand May 26, 2026
d6603a7
New Crowdin updates (#3305)
arnaud4d May 27, 2026
9bf89a8
New Crowdin updates (#3306)
arnaud4d May 28, 2026
4a0de3c
feat(aikit): resync doc to remove wrong model name with :
e-marchand May 28, 2026
7dddeea
feat(aikit): report 21R3 4a0de3c4ed322e9608b53cfd47710018c471812a
e-marchand May 28, 2026
e4dc8df
fix(aikit): 21.X link on OpenAI doc has change
e-marchand May 28, 2026
48d73ab
fix(aikit): revert syncing fixes that were not reported to the aikit …
e-marchand May 28, 2026
ab605a4
New Crowdin updates (#3308)
arnaud4d May 29, 2026
8329732
New Crowdin updates (#3309)
arnaud4d May 29, 2026
860df87
Fix/set query lock (#3310)
arnaud4d Jun 1, 2026
ff13214
New Crowdin updates (#3312)
arnaud4d Jun 1, 2026
e42a237
New Crowdin updates (#3313)
arnaud4d Jun 1, 2026
9d9d560
fixed XML syntaxes (#3314)
arnaud4d Jun 1, 2026
8835a20
fix syntax XML and add OpenSSL 4.0 (#3315)
arnaud4d Jun 1, 2026
51aafa4
fix(syntax): error if passing a wrong version version folders
e-marchand Jun 1, 2026
753cea7
New Crowdin updates (#3316)
arnaud4d Jun 2, 2026
09c4919
fix: missing type in syntax for language legacy commands (#3317)
e-marchand Jun 2, 2026
21498a8
collectionclass.md Japanese (#3318)
arnaud4d Jun 3, 2026
1effc25
Feature/fullfill language sections 0306 (#3319)
arnaud4d Jun 3, 2026
9a93e5b
Merge branch '4d:main' into main
arnaud4d Jun 3, 2026
5d5d9b8
Feature/exit code (#3321)
arnaud4d Jun 4, 2026
3ba8a32
New Crowdin updates (#3320)
arnaud4d Jun 4, 2026
8bca488
fix accumulate and desc order 1
arnaud4d Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docs/API/DataClassClass.md
Original file line number Diff line number Diff line change
Expand Up @@ -1243,14 +1243,21 @@ var $results := ds.MyClass.query("myVectorField <= :1"; $comparisonVector)
The **order by** statement is supported in the query string so that entities in the resulting entity selection are sorted by similarity. For example:

```4d
var $results := ds.MyClass.query("myVectorField > :1 order by myVectorField"; $comparisonVector)
//default order, the first entity is the most similar
var $results := ds.MyClass.query("myVectorField > :1 order by myVectorField desc"; $comparisonVector)
//the first entity is the most similar
```

:::note

The default order is ascending, although a descending order is usually the most useful for vector similarity queries. Thus, you will usually have to add the `desc` keyword in your vector similarity query strings.

:::


If the same vector appears multiple times in the query string, the order by will be applied to the results of the first one, for example:

```4d
var $results := ds.MyClass.query("myVectorField > :1 and myVectorField > :2 order by myVectorField" desc; /
var $results := ds.MyClass.query("myVectorField > :1 and myVectorField > :2 order by myVectorField desc"; /
{vector : $myVector1 };{vector : $myVector2 }) //myVectorField > :1 is used for the order by
```

Expand Down
42 changes: 42 additions & 0 deletions docs/Concepts/dt_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ If you assign an element's index that surpasses the last existing element of the
//myCol[4]=null
```



## Instantiation

Collections must have been instantiated, otherwise trying to read or modify their elements will generate a syntax error.
Expand Down Expand Up @@ -112,6 +114,46 @@ You can create two types of collections:

For more information, refer to the [Shared objects and collections](shared.md) section.


## Assignment

Collection and [object](./dt_object.md) data types are handled in the 4D language through **references** (i.e., internal pointers), unlike scalar data types (integer, date, etc.). As a result, when assigning a collection to a variable (e.g. `$myVar:=[1;2;3]`), it is the **reference** that is assigned, not the value itself. Any subsequent modification of the *$myVar* variable will therefore be reflected everywhere the original collection is referenced. This follows the same principle as [pointers](./dt_collection.md), except that the *$myVar* variable does not need to be dereferenced.

For example:

```4d
var $col1; $col2 : Collection
var $o : Object

$col1:=[1;2;3] //a reference to the collection is created
$col2:=$col1 //both variables share the same collection reference
$o:={ list:$col1 } //the object stores a reference to the same collection

$col1.push(4)
//$col2 = [1,2,3,4]
//$o = {"list":[1,2,3,4]}

$col2[0]:=10
//$col1 = [10,2,3,4]
//$o = {"list":[10,2,3,4]}

$o.list.push(5)
//$col1 = [10,2,3,4,5]
//$col2 = [10,2,3,4,5]

ASSERT($col1=$col2) //True
```

This principle applies wherever objects or collections are assigned, including in [parameters](./parameters.md) or [formula](../commands/formula) expressions.

:::note

If you want to create a **deep copy** of a collection, use the [`collection.copy()`](../API/CollectionClass.md#copy) function.

:::



## Collection functions

4D collection references benefit from special class functions (sometimes named *member functions*). Collection functions are listed in the [Class API Reference](../API/CollectionClass.md) section.
Expand Down
38 changes: 37 additions & 1 deletion docs/Concepts/dt_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ Keep in mind that property names differentiate between upper and lower case.
:::


You manage Object type variables, fields or expressions using the standard [object notation](#properties) or the commands available in the **Objects (Language)** theme. Note that specific commands of the **Queries** theme such as `QUERY BY ATTRIBUTE`, `QUERY SELECTION BY ATTRIBUTE`, or `ORDER BY ATTRIBUTE` can be used to carry out processing on object fields.
You manage Object type variables, fields or expressions using the standard [object notation](#properties) or the commands available in the **Objects (Language)** theme.

Each property value accessed through the object notation is considered an expression. You can use such values wherever 4D expressions are expected:

- in 4D code, either written in the methods (Code Editor) or externalized (formulas, 4D tags files processed by `PROCESS 4D TAGS` or the Web Server, export files, 4D Write Pro documents...),
- in the Expression areas of the Debugger and the Runtime explorer,
- in the Property list of the Form editor for form objects: Variable or Expression field as well as various selection list box and columns expressions (Data Source, background color, style, or font color).






## Instantiation

Objects must have been instantiated, otherwise trying to read or modify their properties will generate a syntax error.
Expand Down Expand Up @@ -122,6 +127,37 @@ You can create two types of objects:
For more information, refer to the [Shared objects and collections](shared.md) section.


## Assignment

Object and [collection](./dt_collection.md) data types are handled in the 4D language through **references** (i.e., internal pointers), unlike scalar data types (integer, date, etc.). As a result, when assigning an object or a collection to a variable (e.g. `$myVar:={ a:2 }`), it is the **reference** that is assigned, not the value itself. Any subsequent modification of the *$myVar* variable will therefore be reflected everywhere the original object is referenced. This follows the same principle as [pointers](./dt_collection.md), except that the *$myVar* variable does not need to be dereferenced.

For example:

```4d
var $o1; $o2 : Object
var $col : Collection

$col:=[1;2;3] //a reference to the collection is created
$o1:={ a:2 ; b:$col } //a reference to the object is created
$o2:=$o1 //both variables $o1 and $o2 share the reference to the same object

$o1.a:=10 //$o2 = {"a":10,"b":[1,2,3]}
$o2.a:=20 //$o1 = {"a":20,"b":[1,2,3]}
$col.push(4)
//$o1 = {"a":20,"b":[1,2,3,4]}
//$o2 = {"a":20,"b":[1,2,3,4]}
ASSERT($o1=$o2) //True
```

This principle applies wherever objects or collections are used, including in [parameters](./parameters.md) or [formula](../commands/formula) expressions.


:::note

If you want to create a **deep copy** of an object, use the [`OB COPY`](../commands/ob-copy) command.

:::


## Properties {#properties}

Expand Down
22 changes: 22 additions & 0 deletions docs/Concepts/flow-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,3 +799,25 @@ logConsole($message)

```

## defer (expression)

<details><summary>History</summary>

|Release|Changes|
|---|---|
|21 R4|Added
</details>


The [`defer`](../commands/defer) command allows you to stack one or more expression(s) that will automatically execute when the current method or function **finishes running**.

Whether you are managing document closings, resetting interprocess flags, or freeing up resources, ensuring that your housekeeping tasks execute flawlessly no matter how or where your function terminates can be handled by `defer` keywords.


```4d
//make sure some code is executed at exit
defer(myCleaningMethod)
//Do something...
```

See the [`defer`](../commands/defer) command description for more information.
2 changes: 1 addition & 1 deletion docs/Concepts/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ In the 4D Language, there are several categories of methods. The category depend
|**Form method**|Automatic, when an event involves the form to which the method is attached|No|Property of a form. You can use a form method to manage data and objects, but it is generally simpler and more efficient to use an object method for these purposes.|
|**Trigger** (aka *Table method*)|Automatic, each time that you manipulate the records of a table (Add, Delete and Modify)|No|Property of a table. Triggers are methods that can prevent "illegal" operations with the records of your database.|
|**Database method**|Automatic, when a working session event occurs|Yes (predefined)|There are 16 database methods in 4D. |
|**Class**|Automatically called when an object of the class is instantiated or when a function of the class is executed on an object instance in any other methods or in a [database field](../Develop/field-properties.md#class).|yes (class functions)|A **Class** is used to declare and configure the class [constructor](./classes.md#class-constructor), [properties](./classes.md#property), and [functions](./classes.md#function) of objects. See [**Classes**](classes.md) |
|**Class**|Automatically called when an object of the class is instantiated or when a function of the class is executed on an object instance in any other methods or in a [database field](../Develop/field-properties.md#class).|yes (class functions)|A **Class** is used to declare and configure the class [constructor](./classes.md#class-constructor), [properties](./classes.md#property), and [functions](./classes.md#function) of objects. See [**Classes**](classes.md) and [**Function** class](../API/FunctionClass.md). |


7 changes: 5 additions & 2 deletions docs/Concepts/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ The values that operators affect are operands. In the expression `1 + 2`, the +
The **assignment operator** (`a:=b`) initializes or updates the value of `a` with the value of `b`:

```4d
$myNumber:=3 //assigns 3 to MyNumber variable
$myDate:=!2018/01/21! //assigns a date literal
$myNumber:=3 //assigns 3 to $myNumber variable
$myDate:=!2026/01/21! //assigns a date literal
$myLength:=Length("Acme") //assigns the result of the command (4) to $myLength
$col:=New collection //$col is initialized with an empty collection
$myObject:={ a:2 ; b:$col } //assigns an object reference to $myObject
$myObject.a:=3 //assigns a value to an object property
```

> Do NOT confuse the assignment operator `:=` with the equality comparison operator `=`. A different assignment operator (and not `=`) was deliberately chosen to avoid issues and confusion which often occur with == or === in other programming languages. Such errors are often difficult to recognize by the compiler and lead to time-consuming troubleshooting.



## Basic operators

Operator results depend on the **data types** they are applied to. 4D supports different operators on scalar data types. They are described with the data types, in the following sections:
Expand Down
10 changes: 10 additions & 0 deletions docs/Notes/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ id: updates
title: Release Notes
---

## 4D 21 R4

Read [**What’s new in 4D 21 R4**](https://blog.4d.com/whats-new-in-4d-21-r4/), the blog post that lists all new features and enhancements in 4D 21 R4.

#### Highlights

- New [`defer`](../commands/defer) command to declare some code to be always executed at method or function exit.



## 4D 21 R3

Read [**What’s new in 4D 21 R3**](https://blog.4d.com/whats-new-in-4d-21-r3/), the blog post that lists all new features and enhancements in 4D 21 R3.
Expand Down
4 changes: 2 additions & 2 deletions docs/language-legacy/Formulas/execute-formula.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ displayed_sidebar: docs

The statement string must be one line. If *statement* is an empty string, **EXECUTE FORMULA** does nothing. The rule of thumb is that if the *statement* can be executed as a one-line method, then it will execute properly. Use **EXECUTE FORMULA** sparingly, as it can slow down execution speed. In a compiled database, the line of code is not compiled. This means that *statement* will be executed, but it will not have been checked by the compiler at compilation time.

**Note:** Executing formulas in compiled mode can be optimized using a cache (see *Cache for formulas in compiled mode* below).
**Note:** Executing formulas in compiled mode can be optimized using a cache (see [Cache for formulas in compiled mode](#cache-for-formulas-in-compiled-mode) below).

The *statement* can include the following elements:

Expand All @@ -46,7 +46,7 @@ The *statement* can include the following elements:
* If *statement* is a project method, it is recommended to use the [EXECUTE METHOD](../commands/execute-method) that allows you to pass parameters.
* It is not recommend to call any variable declaration in *statement* since it can generate conflicts in the code.

The formula can include process variables and interprocess variables. However, the statement cannot contain control of flow statements (If, While, etc.), because it must be in one line of code.
The formula can include process variables and interprocess variables. However, the statement cannot contain control of flow statements (If, While, Return, Break, etc.), because it must be in one line of code. These keywords will be ignored.

To ensure that the *statement* will be evaluated correctly regardless of the 4D language or version used, we recommend using the *token* syntax for elements whose name might vary between different versions (commands, tables, fields, constants). For example, to insert the [Current time](../commands/current-time) command, enter '**Current time:C178**'. For more information about this, refer to *Using tokens in formulas*.

Expand Down
2 changes: 1 addition & 1 deletion docs/language-legacy/Formulas/formula.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ displayed_sidebar: docs

## Description

The `Formula` command <!-- REF #_command_.Formula.Summary -->creates a `4D Function` object based upon the *formulaExp* expression<!-- END REF -->. *formulaExp* can be as simple as a single value or complex, such as a project method with parameters.
The `Formula` command <!-- REF #_command_.Formula.Summary -->creates a `4D Function` object based upon the *formulaExp* expression<!-- END REF -->. *formulaExp* can be as simple as a single value or complex, such as a project method with parameters. For more information on what *formulaExp* can contain, please refer to the [`EXECUTE FORMULA`](../commands/execute-formula) command description.

Having a formula as an object allows it to be passed as a parameter (calculated attribute) to commands or methods or to be executed from various components without needing to declare them as "shared by components and host database". When called, the formula object is evaluated within the context of the database or component that created it.

Expand Down
127 changes: 127 additions & 0 deletions docs/language-legacy/Interruptions/defer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
id: defer
title: defer
slug: /commands/defer
displayed_sidebar: docs
---

<!--REF #_command_.defer.Syntax-->**defer** ( *exitFormula* : Expression )<!-- END REF-->
<!--REF #_command_.defer.Params-->
<div class="no-index">

| Parameter | Type | | Description |
| --- | --- | --- | --- |
| exitFormula | Expression | &#8594; | Expression to be executed at exit|
</div>
<!-- END REF-->

<div class="no-index">
<details><summary>History</summary>

|Release|Changes|
|---|---|
|21 R4|Created|

</details>
</div>

## Description

<!--REF #_command_.defer.Summary-->The `defer` command declares an *exitFormula* expression that will always be executed when the method or function exits, even if an error has been thrown or a `return` has been executed<!-- END REF-->. Using a `defer` command allows you to ensure that a method or function ends correctly by executing completion code on exit. In addition, this command saves you from having to duplicate the same exit code for every return or catch block.

:::tip Related blog post

[Streamline Your Clean-Up Code with the “defer” Command](https://blog.4d.com/streamline-your-clean-up-code-with-the-defer-command)

:::


The `defer` command can be called anywhere in the method or function code, and you can insert as many `defer` expressions as you want in the code. During execution, all encountered *exitFormula* expressions are stacked. When the code execution stops, whatever the reason (normal flow, break, error, user abort, return...), all expressions in the "deferred stack" are popped and executed in LIFO (*Last In First Out)* order.

For example:

```4d
defer(ALERT("1"))
defer(ALERT("2"))
// At exit, alerts will display "2" and then "1"
```

In *exitFormula*, you pass the expression that you want to be evaluated upon method or function exit, whatever the way it exited. Behind the scenes, every time a `defer` is called, 4D converts *exitFormula* into a [formula](../../commands/formula) and adds it to a stack associated with the method or function. When the method or function ends, all formulas stored in the stack are evaluated in the order they appear in the collection.

As for all [formulas](../../commands/formula), if the *exitFormula* expression uses local variables, their current values are copied and stored in the formula object returned **when it is put in the *deferred stack***. When executed, the formula uses these copied values rather than the current values of the local variables.

:::note Notes

- Keep in mind that local variables store **references** for [object](../../Concepts/dt_object.md#assignment) and [collection](../../Concepts/dt_collection.md#assignment) values.
- If *exitFormula* contains another `defer` statement, an error is thrown.

:::

If the *exitFormula* expression throws an error, it is automatically intercepted and ignored and the execution flow continues without any interruption.



## Example 1

These examples illustrate the various supported *exitFormula* expressions:

```4d
// Method call
defer(aMethod)

// Object function call
defer(myObject.aFunction(something))

// Singleton function call
defer(cs.aClass.me.aFunction(something))
```

## Example 2

You want to make sure an XML reference will be always properly released, to avoid potential memory leaks:

```4d
var $xmlRef:=DOM Create XML ref("theRoot")
defer(DOM CLOSE XML($xmlRef))
...
```

## Example 3

You want to make sure the activity monitoring stops at the end of the method:

```4d
START MONITORING ACTIVITY(0.001;Activity all)
defer(STOP MONITORING ACTIVITY())
...
```

## Example 4

You want to control your log generation:

```4d
$logRecording:=Get database parameter(Diagnostic log recording)
SET DATABASE PARAMETER(Diagnostic log recording; 1)
defer(SET DATABASE PARAMETER(Diagnostic log recording; $logRecording))

$logLevel:=Get database parameter(Diagnostic log level)
SET DATABASE PARAMETER(Diagnostic log level; Log trace)
defer(SET DATABASE PARAMETER(Diagnostic log level; $logLevel))
```

## See also

[throw](../commands/throw)
[Last errors](../commands/last-errors)
[ON ERR CALL](../commands/on-err-call)

## Properties

| | |
| --- | --- |
| Command number | 1805 |
| Thread safe | no |



Loading
Loading