Tina4

Tina4 Delphi - Quick Reference#

🔥 Hot Tips

  • Drop components on your form, configure in Object Inspector, and you're ready to go
  • TTina4REST + TTina4RESTRequest = one-line API calls with automatic MemTable population
  • Use SendHttpRequest from Tina4Core for quick one-off REST calls without components
  • TTina4HTMLRender renders HTML with CSS directly on an FMX canvas, including native form controls
  • Twig templates work in both TTina4HTMLRender and TTina4HTMLPages for dynamic content

InstallationQuick WinsREST ClientREST RequestJSON AdapterHTML RendererPage NavigationTwig TemplatesCore UtilitiesClaude AI

Installation#

bash
# Clone the repositorygit clone https://github.com/tina4stack/tina4delphi.git# Open Tina4DelphiProject in Delphi IDE# Build and install Tina4Delphi, then Tina4DelphiDesign

More details on requirements, SSL setup, and project configuration.

Quick Wins#

No components needed - just add Tina4Core to your uses clause and start using these utilities immediately.

Fetch JSON from any REST API in one line:

pascal
var StatusCode: Integer;var Response := SendHttpRequest(StatusCode, 'https://api.example.com', '/products');var Products := BytesToJSONObject(Response);// Products is now a TJSONObject you can iterate, bind to grids, etc.

Turn any database query into JSON:

pascal
var JSON := GetJSONFromDB(FDConnection1, 'SELECT * FROM customers WHERE active = 1');// {"records": [{"id": "1", "firstName": "Andre", "email": "andre@test.com"}, ...]}// Field names are auto-converted to camelCase, dates to ISO 8601, blobs to Base64

Populate a MemTable from JSON - no manual field defs needed:

pascal
PopulateMemTableFromJSON(FDMemTable1, 'records',  '{"records": [{"id": "1", "name": "Alice"}, {"id": "2", "name": "Bob"}]}');// FDMemTable1 is now a live dataset - bind it to a grid, filter it, export it

Upload files with multipart form data:

pascal
var StatusCode: Integer;SendMultipartFormData(StatusCode,  'https://api.example.com', 'upload/avatar',  ['userId', '1001', 'caption', 'Profile photo'],   // form fields  ['avatar', 'C:\photos\me.jpg']);                    // file to upload

More details on string helpers, dates, encoding, JSON, database, and HTTP utilities.


REST Client#

Drop a TTina4REST on your form and configure base URL and auth. Other components reference this for HTTP calls.

pascal
Tina4REST1.BaseUrl := 'https://api.example.com/v1';Tina4REST1.SetBearer('eyJhbGciOiJIUzI1NiJ9...');var StatusCode: Integer;var Response := Tina4REST1.Get(StatusCode, '/users', 'page=1&limit=10');

More details on authentication, HTTP methods, and response handling.

REST Request#

Links to a TTina4REST and executes REST calls with automatic MemTable population.

pascal
// Design-time: set Tina4REST, EndPoint, DataKey, MemTableTina4RESTRequest1.ExecuteRESTCall;// FDMemTable1 is now populated with the response data

More details on POST bodies, master/detail, async execution, and events.

JSON Adapter#

Populates a TFDMemTable from static JSON or from a REST request master source.

pascal
Tina4JSONAdapter1.MemTable := FDMemTable1;Tina4JSONAdapter1.DataKey := 'products';Tina4JSONAdapter1.JSONData.Text := '{"products": [{"id": "1", "name": "Widget"}]}';Tina4JSONAdapter1.Execute;

More details on MasterSource linking and sync modes.

HTML Renderer#

An FMX control that parses and renders HTML with CSS support directly on a canvas.

pascal
Tina4HTMLRender1.HTML.Text := '<h1>Hello</h1><p>This is <b>bold</b> and <i>italic</i>.</p>';

More details on supported HTML/CSS, form controls, events, DOM manipulation, and Twig integration.

Design-time SPA-style page navigation using TTina4HTMLRender.

pascal
Tina4HTMLPages1.Renderer := Tina4HTMLRender1;var Page := Tina4HTMLPages1.Pages.Add;Page.PageName := 'home';Page.IsDefault := True;Page.HTMLContent.Text := '<h1>Home</h1><a href="#about">Go to About</a>';

More details on Twig pages, programmatic navigation, and events.

Frond (Twig) Templates#

A Twig-compatible template engine for rendering dynamic HTML.

pascal
var Twig := TTina4Twig.Create('C:\templates');try  Twig.SetVariable('name', 'Andre');  Memo1.Lines.Text := Twig.Render('<h1>Hello {{ name }}</h1>');finally  Twig.Free;end;

More details on template syntax, filters, and functions.

Core Utilities#

Tina4Core.pas provides standalone utility functions for JSON, dates, encoding, HTTP, and database operations.

pascal
// Convert between naming conventionsCamelCase('first_name');    // 'firstName'SnakeCase('firstName');     // 'first_name'// Date validation and conversionIsDate('2024-01-15T10:30:00.000Z');  // TrueGetJSONDate(Now);                     // '2024-06-15T14:30:00.000Z'// Base64 encodingvar B64 := FileToBase64('C:\photos\avatar.jpg');

More details on all available utility functions.

Working with Claude AI#

Tina4 Delphi ships with an MCP (Model Context Protocol) server that gives Claude Code the ability to compile, run, preview, and interact with Pascal/Delphi applications directly from the CLI.

Install the MCP server:

bash
# From the tina4delphi repositorycd claude-pascal-mcpuv sync

Add it to your Claude Code settings (.mcp.json or project-level):

json
{  "mcpServers": {    "pascal-dev": {      "command": "uv",      "args": ["run", "--directory", "/path/to/claude-pascal-mcp", "pascal-mcp"]    }  }}

What Claude can do with the MCP server:

  • Compile Pascal - compile single-file code or full Delphi projects (DPR + PAS + DFM)
  • Project Templates - generate proper Delphi project structure with components and event handlers
  • Run Programs - compile and execute console programs, capturing stdout/stderr
  • Launch GUI Apps - compile and run VCL/FMX applications in the background
  • Live Preview - see running desktop apps through Claude's preview panel via an HTTP bridge
  • Click Buttons - interact with controls by enumerating child windows and sending clicks directly
  • Move & Resize - reposition and resize application windows programmatically
  • Type & Send Keys - enter text and send keyboard shortcuts to running apps
  • Parse Forms - read .dfm, .fmx, or .lfm form files and understand component structure
  • Auto-detect Compilers - finds Free Pascal, Delphi 7 (dcc32), and RAD Studio (dcc64)
  • Specify Compiler Path - use any compiler by passing its full path

Preview Bridge - Claude can see your running desktop app through its built-in preview panel. Add this to .claude/launch.json:

json
{  "version": "0.0.1",  "configurations": [    {      "name": "pascal-preview",      "runtimeExecutable": "/path/to/.venv/Scripts/pythonw.exe",      "runtimeArgs": ["-m", "pascal_mcp.preview_bridge"],      "port": 18080,      "autoPort": true    }  ]}

This means Claude can write Delphi code, compile it, launch the app, see it running, click buttons, verify behavior, and fix issues, all without leaving the conversation.

↑ Back to top


📕 Download the book#

Tina4Delphi Developer (PDF): full reference, printable, with clickable table of contents and PDF outline. Regenerated with every release.