4d-v21

Comprehensive 4D v21 development expert with embedded official documentation. Covers ORDA patterns, entity classes, data model classes, queries, classic methods, data types, error handling, forms, events, web server, and REST API. Use when working with 4D files (.4dm), 4D language questions, 4D project structure, entity classes, ORDA queries, database operations, form development, web server configuration, REST API usage, or any 4D-specific syntax issue. Includes full official 4D v21 documentation for on-demand retrieval. Triggers on: .4dm files, 4D code, ORDA, entity selection, dataclass, 4D query, 4D form, 4D web server, 4D REST, 4D command, 4D collection, 4D object.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "4d-v21" with this command: npx skills add ganbin/4d-development-skill/ganbin-4d-development-skill-4d-v21

4D Development Expert (v21)

Skill Version

  • 4D Version: v21
  • Skill Version: 1.0
  • Docs: Full official 4D v21 documentation embedded in docs/ (3,387 files)

This skill targets 4D v21 specifically. Do not assume features from other versions exist unless verified in the embedded documentation.


How to Use This Skill

CRITICAL: For any 4D task, ALWAYS prefer reading the embedded documentation files (docs/) over relying on training data. The docs/ folder contains the authoritative 4D v21 reference.

Workflow:

  1. Check this file for critical rules and routing
  2. Read the relevant references/ file for curated knowledge and patterns
  3. If more detail is needed, read the specific docs/ file pointed to by the reference
  4. For edge cases, use grep to search across docs/
  5. Only fall back to training data if docs/ doesn't cover the topic

Priority reading: Always check references/manual-insights.md — it contains real-world corrections from code reviews that override documentation.


Local Conventions

Before providing 4D guidance, check if a local/ directory exists in this skill folder with project-specific conventions:

ls local/*.md 2>/dev/null

If files exist, read them first. The local/ directory (gitignored) can contain:

  • Company-specific naming conventions and documentation standards
  • Project-specific database schemas
  • Version overrides (e.g., if project uses 4D v19.2 instead of v21)

Critical Syntax Rules

These are the most common sources of bugs in 4D code. Know them by heart.

1. Assignment vs Comparison

// WRONG: = is comparison, returns True/False
$name = Request("Enter name")        // Compares, doesn't assign!
If ($input = Request("Name"))        // WRONG: compares, doesn't assign

// CORRECT: := is assignment
$name:=Request("Enter name")        // Assigns
$input:=Request("Name")
If ($input # "")                     // Then compare separately

Rule: := assigns. = compares. Never mix them.

2. Object Properties Are Case-Sensitive

// Variables: case-INSENSITIVE
$MyVar:="test"
$myvar:="changed"            // Same variable!

// Object properties: case-SENSITIVE
$obj.Name:="John"
$obj.name:="Jane"            // Different properties!

3. Collection vs Array Indexing

// Collections: 0-based
$col:=New collection("A"; "B"; "C")
$first:=$col[0]              // "A"

// Arrays: 1-based with special element zero
ARRAY TEXT($arr; 3)
$arr{1}:="A"                 // First element
$arr{0}:="default"           // Special element zero

4. Null Queries Require Literal Syntax

// WRONG: Null as placeholder doesn't work
$result:=ds.Users.query("email = :1"; Null)

// CORRECT: literal null in query string
$result:=ds.Users.query("email = null")
$active:=ds.Users.query("email != null")

5. Linked Collection Queries

// WRONG: conditions can match DIFFERENT collection elements
ds.Users.query("projects[].status = 'active' AND projects[].budget > 1000")

// CORRECT: [a] links conditions to the SAME element
ds.Users.query("projects[a].status = 'active' AND projects[a].budget > 1000")

6. Numeric Object Properties Are Always Real

$obj:=New object("count"; 5)
Value type($obj.count)  // Returns Is real, NEVER Is longint

7. Decimal Separator Is Always Period

$price:=19.99    // CORRECT — always period
$price:=19,99    // WRONG — two separate numbers!

8. 4D has a strict left-to-right precedence

if ($length > 1+$i) // Runtime error: $length>1 -> true -> true+$i -> error
if ($length > (1+$i)) // No error

$result:=3+4*5 // 35
$result:=3+(4*5) // 23

Quick Decision Router

By Task

TaskRead FirstThen If Needed
Syntax errors, operatorslanguage-syntax.mddocs/Concepts/operators.md
Data types, conversionsdata-types.mddocs/Concepts/data-types.md
ORDA, entity classesorda-modern.mddocs/ORDA/ordaClasses.md
Database queriesquery-patterns.mddocs/API/DataClassClass.md
Error handlingerror-handling.mddocs/Concepts/error-handling.md
Legacy/classic codeclassic-patterns.mddocs/Concepts/arrays.md
Forms, events, UIforms-and-ui.mdevents-index.md
Web server, REST APIweb-and-rest.mdrest-index.md
Specific class APIapi-index.mddocs/API/{ClassName}Class.md
Specific commandcommands-index.mddocs/commands/{name}.md
Legacy commandlegacy-commands-index.mddocs/commands-legacy/{name}.md

By Error / Symptom

Error or SymptomRead
"Type mismatch" or wrong typedata-types.md
"Cannot use = to assign" / silent assignment buglanguage-syntax.md
Query returns wrong resultsquery-patterns.md
"Null query" not workingmanual-insights.md
Entity/EntitySelection methodsorda-modern.md then api-index.md
Form events not firingforms-and-ui.md then events-index.md
Process variables not workingclassic-patterns.md
REST endpoint 404 or auth errorweb-and-rest.md
Transaction or save errorerror-handling.md
local keyword confusionmanual-insights.md
Need to find a specific 4D commandcommands-index.md
Need to find a legacy commandlegacy-commands-index.md

Docs Navigator

The docs/ folder contains the full official 4D v21 documentation (3,387 files, 48MB). Use this section to find the right file.

Category Quick Lookup

NeedDirectoryFile PatternExample Path
Class API referencedocs/API/{Class}Class.mddocs/API/CollectionClass.md
ORDA conceptsdocs/ORDA/{topic}.mddocs/ORDA/entities.md
Modern commandsdocs/commands/{command-name}.mddocs/commands/dialog.md
Commands by themedocs/commands/theme/{Theme}.mddocs/commands/theme/JSON.md
Language conceptsdocs/Concepts/{topic}.mddocs/Concepts/classes.md
REST endpointsdocs/REST/${endpoint}.mddocs/REST/$filter.md
Form eventsdocs/Events/on{Event}.mddocs/Events/onClicked.md
Form objectsdocs/FormObjects/{type}_overview.mddocs/FormObjects/listbox_overview.md
Web serverdocs/WebServer/{topic}.mddocs/WebServer/sessions.md
Legacy commandsdocs/commands-legacy/{command-name}.mddocs/commands-legacy/alert.md
Settingsdocs/settings/{topic}.mddocs/settings/web.md
Project structuredocs/Project/{topic}.mddocs/Project/architecture.md
AI Kitdocs/aikit/variousdocs/aikit/
ViewProdocs/ViewPro/variousdocs/ViewPro/
WriteProdocs/WritePro/variousdocs/WritePro/

Search Patterns

When you need to find something specific across docs/:

# Find a command by name
grep -rl "title: CommandName" docs/commands/ docs/commands-legacy/

# Find a class method
grep -rl "\.methodName" docs/API/

# Find usage of a specific function
grep -rl "functionName" docs/ --include="*.md"

# Find a form event
ls docs/Events/on*.md

# Find a form object type
ls docs/FormObjects/*_overview.md

# Find a REST endpoint
ls docs/REST/\$*.md

# Find settings for a topic
grep -rl "keyword" docs/settings/

# Find a legacy command by theme
grep -rl "CommandName" docs/commands/theme/

Index Files

For structured navigation of large categories, read these generated indexes:

IndexContentFiles Indexed
api-index.mdAll API classes with key methods42
commands-index.mdModern commands + theme categories65 + 76
concepts-index.mdLanguage concept files29
orda-index.mdORDA documentation structure10
rest-index.mdREST API endpoints36
events-index.mdForm and system events61
form-objects-index.mdForm object types54
webserver-index.mdWeb server documentation14
legacy-commands-index.mdLegacy commands by theme1,211
all-categories-index.mdMaster navigation32 categories

Reference Files Guide

Curated Knowledge (hand-written, with code examples)

FileCoversPriority
language-syntax.mdAssignment, operators, control flow, methods, classes, strings, formulasHigh — read for any syntax question
data-types.mdAll types, conversions, null/undefined, collections, objects, pointersHigh — read for type errors
orda-modern.mdORDA architecture, entity classes, computed attributes, shared objects, signalsHigh — read for new feature development
query-patterns.mdQuery syntax, placeholders, null queries, linked collections, formulas, performanceHigh — read for any query work
error-handling.mdTry/Catch, ON ERR CALL, transactions, Throw, loggingMedium — read when handling errors
classic-patterns.mdArrays, process variables, pointers, sets, migration strategiesMedium — read for legacy code
forms-and-ui.mdForms, events, form objects, list boxes, subforms, form classesMedium — read for UI work
web-and-rest.mdWeb server, REST API, HTTP handlers, sessions, authenticationMedium — read for web/REST work
manual-insights.mdReal-world corrections from code reviews — overrides other sourcesAlways check for edge cases

Common Workflows

New Feature Development:

  1. orda-modern.md for architecture patterns
  2. query-patterns.md for database operations
  3. error-handling.md for robust error management
  4. Specific docs/API/ files for class method details

Legacy Code Maintenance:

  1. classic-patterns.md for understanding legacy code
  2. orda-modern.md for modernization options
  3. language-syntax.md for syntax questions

Debugging:

  1. Check Critical Syntax Rules above first
  2. language-syntax.md for syntax errors
  3. data-types.md for type errors
  4. query-patterns.md for query issues
  5. manual-insights.md for known gotchas

Web/REST Development:

  1. web-and-rest.md for server and REST patterns
  2. orda-modern.md for exposed functions
  3. rest-index.md for specific endpoint docs

External Resources

When the embedded docs don't cover your case:

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated
Coding

ai-dating

This skill enables dating and matchmaking workflows. Use it when a user asks to make friends, find a partner, run matchmaking, or provide dating preferences/profile updates. The skill should execute `dating-cli` commands to complete profile setup, task creation/update, match checking, contact reveal, and review.

Archived SourceRecently Updated
Coding

clawhub-rate-limited-publisher

Queue and publish local skills to ClawHub with a strict 5-per-hour cap using the local clawhub CLI and host scheduler.

Archived SourceRecently Updated