Skip to content
twinbasicPublic

About

Official twinBASIC sample projects demonstrating the features and capabilities of the twinBASIC programming language and IDE.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[twinBASIC

Samples

This repository hosts online copies of all the built-in twinBASIC sample projects. The IDE ships with 30 sample projects, in the Samples section of the New / Open Project dialog. This readme says how a sample opens, what each one shows, and what it needs before it runs. You do not need to download these to use them, all samples are already included in the IDE and can be opened from that dialog without any additional files from this repository.

How a sample opens

A sample opens like a template. Double-click its card, or select it and press Open. The New Project Options box opens first. Continue makes the sample as a new project, unsaved, in memory. The first save asks for a file name, and the sample on disk stays as it is. See What a new project is.

The box’s rows apply to a sample too. The Project Name starts as the sample’s own project name, such as HelloWorldProject for HelloWorld, and Continue sets the project’s name, description and application title to the text of the box.

A card shows the sample’s name without its number, and the cards are in the order of the numbers. The numbering is the IDE’s own: 1a and 1b follow 1, and 10 follows 9. The documentation names a sample by its number, as in Sample 6, so the table below gives both.

Where a sample builds

Samples 10 to 16 build into the IDE’s own folder. Their Build Output Path is ${IdePath}\addins\${Architecture}\${ProjectName}.${FileExtension}, so a build of one installs the add-in in the folder of the running IDE, as addins\win32 or addins\win64. It loads at the next start of the IDE. Holding Shift while a project loads stops add-ins loading; see Opening projects. Add Ins describes add-ins.

Samples 24 to 27 build into your own add-ins folder. Their Build Output Path is ${AppData}\twinBASIC\addins\${Architecture}\${ProjectName}.${FileExtension}, so a build installs the add-in in %APPDATA%\twinBASIC\addins\win32 or win64, for every IDE you start. The IDE’s own addins folder holds a copy of each of these four already, under the same name.

The other samples build into a Build folder beside the project’s file, once the project is saved.

Before you run a sample

Most samples run with Start (F5) as they are. These need something more.

Samples 3, 4, 5, 7, 9 to 16 and 24 to 27 are not programs. Each makes a DLL, a control or a package, so Start has nothing to run and ends with a compile error in the console. Build them instead:

  • A build of Sample 3, 4, 5 or 9 registers the file for the current user, and Clean removes the registration. The file must match the program that loads it: for 64-bit Office, choose win64 in the build box.
  • The registration of Sample 4 adds it to the VBA editor, and the registration of Sample 5 adds it to Excel and to Access. Each then loads when that program starts.
  • Samples 10 to 16 and 24 to 27 install themselves in the IDE, as Where a sample builds describes.

Sample 23 has no Main, so Start ends with a compile error there too. Open Main.twin, put the caret inside Sub DemoAnimals and press F6. See Run Or Preview.

Samples 1a, 1b and 9 use a browser engine. Samples 1a and 9 need the WebView2 Runtime. Sample 1b needs the CEF runtime, which is a separate download: see Runtime files. The first form of Samples 1a and 1b opens a web site, so it needs a network connection. Samples 1a and 1b make the folders tbVirtualHostDemo and tbMonacoDemo in your Documents folder, and Sample 9 makes tbMonacoActiveXDemo in your local application data folder. These folders stay after the sample ends.

Samples 21 and 22 install Windows services, which needs administrator rights, so they do it only from a built EXE that you start with Run as administrator:

  • Sample 21 only shows a message box in the IDE. The built EXE offers to install the service, TBSERVICE000, which then starts on demand. The sample has no command that removes it. To remove it, run sc delete TBSERVICE000 from a command prompt started as administrator.
  • Sample 22 opens its form in the IDE too, but Install refuses there. Its Uninstall buttons remove the services. Launch in-process named pipe server needs no service, so you can try the form’s named pipes without installing anything.

See Also

  • New Project – the dialog, and New Project Options
  • What Start runs – the startup object, and what Start does without one
  • Add Ins – the add-in samples, 10 to 16 and 24 to 27

The samples

Reports (Experimental)

  • Project type: Standard EXE
  • What it shows: A form that opens two reports. One takes its rows from an ADODB recordset made in memory, the other from a class that implements ITbRecordset

HelloWorld

  • Project type: Standard EXE
  • What it shows: The smallest program: a Sub Main that shows a message box

WebView2 Examples

  • Project type: Standard EXE
  • What it shows: Four forms on the WebView2 control: a browser with a log of its events, a local web page that exchanges calls with twinBASIC, the Monaco editor with a live preview, and a Markdown preview. Uses the WebView2 package
  • Additional documentation: the WebView2 tutorials

Chromium Embedded Framework Examples

  • Project type: Standard EXE
  • What it shows: The same four forms on the CefBrowser control. Uses the CEF package
  • Additional documentation: the CEF tutorials

GetIPAddresses

  • Project type: Standard EXE
  • What it shows: Calls the Windows API through Declare, and shows the machine’s IPv4 addresses in a message box
  • Project type: ActiveX DLL
  • What it shows: A COM class with one method, for a host such as VBA to call

MyVBEAddin (NEW with ToolWindow)

  • Project type: ActiveX DLL
  • What it shows: An add-in for the VBA editor: a tool window made from a user control, and an item on the editor’s Add-Ins menu that shows or hides it. References the Microsoft Add-In Designer and the VBA Extensibility 5.3 type libraries
  • Additional documentation: the FAQ on add-ins

MyCOMAddin

  • Project type: ActiveX DLL
  • What it shows: A COM add-in for Excel and Access: a ribbon tab, twinBASIC Test, with a button that shows a message box. References the Microsoft Add-In Designer and the Office 16.0 object library
  • Additional documentation: the FAQ on add-ins

CustomControls

  • Project type: Standard EXE
  • What it shows: Ten forms, each opening the next, on the controls of the CustomControls package: anchoring, borders and corners, buttons, a data grid, docking, fill patterns, a slider, text boxes and text rendering
  • Additional documentation: the CustomControls tutorial
  • Project type: Package TWINPACK
  • What it shows: The smallest package: a class and a module, each with a Show method
  • Additional documentation: Creating a TWINPACK Package

FilePropertyViewer (CustomControls)

  • Project type: Standard EXE
  • What it shows: A form that asks for a file and lists its properties in a grid. Uses the CustomControls package and the FileProps package

ActiveX Control WebView2 + Monaco

  • Project type: ActiveX Control
  • What it shows: A control for other programs to host. It holds the Monaco editor in a WebView2, with two events and two methods that read and set the text. Uses the WebView2 package
  • Additional documentation: the WebView2 tutorial on the user data folder

twinBASIC IDE Addin

  • Project type: Standard DLL
  • What it shows: Two toolbar buttons and a tool window of buttons that call the Host object: the project, the DEBUG CONSOLE and the active editor
  • Additional documentation: Add Ins, the FAQ on add-ins and the tbIDE reference

twinBASIC IDE Addin (Chart)

  • Project type: Standard DLL
  • What it shows: A line chart in a tool window, which an AddinTimer updates every half second with random numbers
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (Monaco)

  • Project type: Standard DLL
  • What it shows: A Monaco editor in a tool window. Each change prints the text to the DEBUG CONSOLE
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (ListView)

  • Project type: Standard DLL
  • What it shows: A list in a tool window, with rows of HTML, icons from a style sheet in the project, and a text box in one row. Clicks and key presses reach twinBASIC as events
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (VirtualListView)

  • Project type: Standard DLL
  • What it shows: A list of 5 million rows in a tool window, which asks twinBASIC for the HTML of a row only when it needs the row
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (GlobalSearch)

  • Project type: Standard DLL
  • What it shows: The project of the Global Search add-in that ships with the IDE: a search of the project’s files in a tool window, where a click opens a match
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (TODO Widgets demo)

  • Project type: Standard DLL
  • What it shows: Two toolbar buttons that add a TODO note as a widget inside the code editor and list the notes in a tool window. The notes are saved in the project

Static Library Example (SQLITE3)

  • Project type: Standard EXE
  • What it shows: Links SQLite into the EXE from .obj files, so that the EXE needs no DLL. It makes a database in memory, adds three rows and shows each in a message box
  • Additional documentation: Static Linking

Static Library Example (libdeflate)

  • Project type: Standard EXE
  • What it shows: Links libdeflate into the EXE from .a files in the same way. It compresses a string and expands it again, and prints the bytes to the DEBUG CONSOLE
  • Additional documentation: Static Linking

MDI Forms

  • Project type: Standard EXE
  • What it shows: An MDI form with red and blue child forms. Its File menu adds a child, and its Window menu arranges and lists them

TreeView + ListView + ImageList

  • Project type: Standard EXE
  • What it shows: A form of buttons that fill and clear a TreeView and a ListView, change their icons from an ImageList and switch the ListView’s views. Uses the WinNativeCommonCtls package

Windows Service Simple Example

  • Project type: Standard EXE
  • What it shows: A Windows service that runs for 15 seconds, in an EXE that installs itself. Uses the WinServicesLib package

Windows Service Complex Example (inc Event Logging and IPC)

  • Project type: Standard EXE
  • What it shows: Two services in one process, which write to the event log and answer requests over named pipes, and a form that installs, starts, stops and queries them. Uses the WinServicesLib, WinEventLogLib and WinNamedPipesLib packages

OOP Inheritance Example (Animals)

  • Project type: Standard EXE
  • What it shows: A small class hierarchy that prints to the DEBUG CONSOLE, with Inherits, Protected, Overridable, Overrides and an inherited event
  • Additional documentation: Inheritance

twinBASIC IDE Addin (Designer Hex Editor)

  • Project type: Standard DLL
  • What it shows: The project of the Hex Editor add-in that ships with the IDE: an editor of a file’s bytes in a tab of its own, used for .bin and .dat files and offered for every other file
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (Designer ICO Editor)

  • Project type: Standard DLL
  • What it shows: The project of the ICO Designer add-in that ships with the IDE: an editor of .ico files, with its drawing tools in the TOOLBOX
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (Designer Diff Compare)

  • Project type: Standard DLL
  • What it shows: The project of the Diff Compare add-in that ships with the IDE: commands in the Project Explorer’s menu that compare two files side by side, in one IDE or across two
  • Additional documentation: the tbIDE reference

twinBASIC IDE Addin (Designer Data Explorer)

  • Project type: Standard DLL
  • What it shows: The project of the Data Explorer add-in that ships with the IDE: a read-only view of a database in the IDE’s datasheet grid, kept in a .tbdata file. References ADO 6.0
  • Additional documentation: the tbIDE reference

Samples 10 to 16 and 24 to 27 use the tbIDE package, and its reference uses Samples 10 to 15 and 24 to 27 as its examples.

About

Official twinBASIC sample projects demonstrating the features and capabilities of the twinBASIC programming language and IDE.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages