Install
npx skillscat add jaimealvarezv/4d-development-skill-v20 Install via the SkillsCat registry.
SKILL.md
4D v20 Development Skill
This skill provides expert knowledge for developing in 4D v20. It includes embedded official documentation and best practice guides tailored for version 20.
๐ Documentation Router
| Topic | Reference File | Description |
|---|---|---|
| Language Syntax | language-syntax.md | var, operators, control flow, v20 specifics. |
| Data Types | data-types.md | Collections, Objects, Variants, typing rules. |
| ORDA | orda-modern.md | Entity Selections, DataClass, optimization. |
| Queries | query-patterns.md | Placeholders, formula queries, optimization. |
| Error Handling | error-handling.md | ON ERR CALL, Try/Catch (check availability). |
| Web & REST | web-and-rest.md | Web Server, REST API, HTTPRequest. |
| Forms & UI | forms-and-ui.md | Form objects, events, list boxes. |
โ ๏ธ Critical v20 Rules
- Variable Declaration: ALWAYS use
var $name : Type. AvoidC_TEXTunless modifying legacy code. - Assignment: Use
:=for assignment found in legacy/standard mode. v20 allows=in some contexts but:=is safer for compatibility.- Note: If "Use standard assignment =" option is on,
=is fine. Default to:=to be safe.
- Note: If "Use standard assignment =" option is on,
- Collections vs Arrays: Prefer Collections (
[]) and Objects ({}) over Arrays (ARRAY TEXT). - Query Literals: Use placeholders (
:1,:2) or: $var. NEVER concat strings into queries (SQL injection checks).- Safe:
ds.Users.query("name = :1", $name)
- Safe:
- Null: Use
Nullkeyword. Check withUnknown valueorAsserthelper if needed. - Linked Collections: When using
[table], remember it returns a selection. To get a collection, useds.Table.all().toCollection().
๐ซ v21+ Features to AVOID (v21-only)
Do NOT use the following features unless you are certain the project is v20 R7+ or v21:
- HTTP Classes:
4D.IncomingMessage,4D.OutgoingMessage(v20 R6+). UseOn Web Connection/WEB GET BODYfor standard v20 servers. - File Handles:
4D.File.Handle(v21). UseFileandDocument to text/Text to documentorFile.getContent(). - Singleton Classes:
shared singleton Class. UseStoragefor singletons in v20. - Try/Catch: Available in v20 R4+. If base v20, use
ON ERR CALL. Verify exact v20 R-release.
๐ Searching Documentation
The official 4D v20 documentation is embedded in the docs/ directory.
To find information about a command or class:
- Search References: Check
references/first for high-level patterns. - Grep Docs: Use
grep_searchorfind_by_nameindocs/folder.- Example:
grep -r "HTTP Request" docs/
- Example:
- API Index: See api-index.md for a map of standard commands.
REST Contract
When building REST APIs in v20:
- Success:
{ "ok": true, "data": ... } - Error:
{ "ok": false, "error": { "code": 123, "message": "..." } } - Use
Web Serverclass orOn Web Connectiondatabase method.