FormCast lets a TCC v36+ batch script (.btm) build native Windows GUI
forms with the same handle-based vocabulary you already use for
@SM* and @B* handles. This page walks you from "plugin loaded"
to "form on screen with a button that calls a script function" in
about a minute.
- Download the latest FormCast release zip from the releases page.
- Extract the zip to a permanent location (e.g.
C:\FormCast\). Keep all DLLs together — the plugin needs its dependency DLLs in the same directory asFormCast.dll. - Set the
FORMCAST_DLLenvironment variable so BTM scripts can find it:(Add this to your TCC startup file or system environment for persistence.)set FORMCAST_DLL=C:\FormCast\FormCast.dll - Load it with
plugin /l %FORMCAST_DLL.
@FORMVERSION returns the plugin version when the load succeeded:
plugin /l FormCast.dll
echo %@formversion[]
Save as hello.btm and run it from a TCC prompt:
@echo off
setlocal
call formcast-check.btm load
set h=%@formopen[form,hello,200,200,300,120]
%@formset[%h,.,title,Hello]
%@formadd[%h,lbl,LABEL,10,10,260,20,What is your name?]
%@formadd[%h,txt,EDIT,10,35,260,22,]
%@formadd[%h,btn,BUTTON,200,65,70,25,OK]
%@formshow[%h]
:loop
do ev in /p formevents %h
set KIND=%@word[" ",1,%ev]
set CTRL=%@word[" ",2,%ev]
iff "%KIND" == "click" .and. "%CTRL" == "btn" then
goto done
endiff
iff "%KIND" == "close" then
goto done
endiff
enddo
goto loop
:done
set name=%@formget[%h,txt,text]
%@formclose[%h]
echo Hello, %name
endlocal
formcast-check.btm is the shared helper that loads the plugin (or
verifies it is already loaded). It replaces the older
formcast-load.btm. The FORMEVENTS polling loop is the recommended
event-handling pattern -- it avoids the thread-safety pitfalls of
@FORMBIND + gosub from a callback thread.
Every FormCast form follows the same four-step pattern:
- Open a handle:
set h=%@formopen[form,name,x,y,w,h] - Add controls:
%@formadd[%h,id,TYPE,x,y,w,h,text] - Show the form:
%@formshow[%h] - Poll for events:
do ev in /p formevents %h
When you're done, %@formclose[%h] tears it down. The forced-shutdown
contract guarantees that plugin /u FormCast cleans up every form
FormCast created, so you can always recover with a fresh load.
Templates: instead of building forms imperatively, you can load a
JSONC template: set h=%@formload[myform.jsonc]. Many of the example
BTMs (04, 05, 09, 11, 12, 13, 14, 15) have been converted to load
from templates in the templates/ directory.
| Topic | Read |
|---|---|
| Common questions by category | FAQ |
| All variable functions and commands | Function Reference |
| Step-by-step worked examples | Tutorial |
| Saving and loading templates | Template Reference |
| Building forms in a designer | Designer Guide |
| How the plugin is wired | Architecture |
| What every term means | Glossary |