BeniBela online


Here you can find all my published sources that you can use as libraries in your projects. Only components for Delphi are on another page. You can use, change and distribute all sources published under the terms of the MPL, GPL or BSD-license in any way you want. Although in the case of the MPL or GPL you must publish changes and you must not change the license. In the case of the GPL you must also publish extensions and the source of all (your) programs using it under the terms of the GPL.
If any of the files is published under the terms of more than one license, you can choose one of them.
You can find more and legally valid information in the source files.

Title Description LanguageLicense
Internet Tools A XPath 2/3/XQuery 1/3/JSONiq engine, a pattern matcher for HTML/XML, an auto update class and a HTTP connection wrapper. FPCGPL
Farbauswahldialog A color select dialog with HLS- and RGB-mode. DelphiGPL
TCommandLineReader An unit for parsing of command line parameters FPC, DelphiGPL
Big Decimal Math An arbitrary precision bcd floating point library FPC(LC)LGPL
Diagram-Tools A diagram component based on a model/view system. FPC/LazarusGPL
BBUtils Often needed functions missing in FPC. Delphi, FPC(LC)LGPL
Non-VCL Canvas A replacement for Delphi's TCanvas not depending on the VCL. DelphiMPL, GPL
Diffreader A unit to read and write unified diffs. FPCGPL
TCVirus An unit/component for the development of joke programs DelphiMPL, GPL
TAutoUpdater An unit for an automatically update FPCGPL
SimpleBrowser A simple IE-based browser (Delphi), (EXE)GPL
Huffmankomprimierer A collection of functions for Huffman (de-)compression. DelphiMPL, GPL

 Internet Tools

2006 - 2016
This package consists of several units working together:

  • The simple html parser at the lowest level, parses an XML/HTML like file and calls callback functions for every tag and text it has read.
  • The html tree parser, uses the simpler parser to read an XML/HTML like file and create a linked element-stream from it, which is equivalent to a dom-like tree. This parser takes much care to make the tree usable, e.g. by correcting errors in invalid html files and auto detecting its encoding.
  • With the XPath / XQuery engine you can then run arbitrary XPath 2.0, XPath 3.0, XQuery 1.0 and XQuery 3.0 queries on the dom-like representation. It is completely implemented in Pascal and pretty much standard conformant. (compare its XQuery Testsuite results: between 100% for XPath 2 and 99% for XQuery 3). It also supports JSONiq.
  • The parser for CSS 3 selectors is part of then XQuery class, converts the CSS selector to a XPath expression and evaluates that.
  • The pattern-matching html template engine at the highest level, can be used to process an HTML file by annotating a subset of it and applying the resulting template to the HTML file. All elements in the template are searched in the HTML file and template instructions in matching elements can be used to extract data. For example a template like
    will read the urls of all links in an HTML file.
    A template like this:
    <table id="foobar"><tr><td>abc</td><td>{.}</td>*</tr>*</table>
    will read all table cells after the cell containing abc in all rows of the table with id foobar. And a template like this:
    <table id="foobar"><tr>{temp := 0}<td>abc</td><td>{temp := $temp + .}</td>*{result := $temp}</tr>*</table>
    will calculate the sum of all table cells after the abc cell in all rows.
    You can also try these templates online or with Xidel.
  • The multi page template engine can be used to download several pages, and apply a single-page template to each of them. Contrary to the single-page template it does not do any pattern matching itself (of course the single-page templates contained in a multi-page template do pattern matching against each page), but simply executes the actions in the order given in the template. It also supports variables, condition and loops, so it is even Turing complete.
  • The http/s-wrapper let you switch dynamically between Wininet (default library installed on every Windows computer), Synapse (platform-independent, but not always installed and problematic with HTTPS) and Apache HttpComponents (called through JNI and runs on Android).
  • The auto update class is a trivial example for the other classes and can be used to add an auto update function to a program which will check online for a more recent version, download that version automatically and (optionally) install it.

Summary of features:

  • Parsers/interpreters:
    • for xml/html files, with a sax or dom-like interface
    • for XPath 2 / XQuery expressions
      • nearly completely standard compatible: passes 99.3% of the XPath 2 only tests and 97.8% of the XQuery 1 tests in the XQuery Testsuite
        (skipping tests for invalid input queries; most failing tests depend on xml schemas which are not supported, yet)
      • Some extension for objects, css, regular expressions, pattern matching and JSONiq
    • ! and || operators of XPath/XQuery 3.0
    • for JSONiq: An extension to XQuery to handle JSON data
    • for CSS 3 Selectors
      • standard compatible (afaik)
      • standalone or within XPath queries //foobar/css("p#x a.class")/@href
    • for pattern-matching html/xml templates:
      • Templates can be easily created/updated from the existing html file
      • The template languages allows the inclusion of regular, XPath 2 / XQuery, JSONiq and CSS 3 Selectors expressions
      • The language has variables, optional elements, loops and conditions
      • e.g. <p class="test"><span>Caption:</span><a>{.}</a>*</p> will read all links after the span-element containing Caption: in a paragraph with class test
    • for multi-page "scraping" templates
      • A collection of pattern-matching template to apply to several webpages
      • has variables, conditions and loops => Turing complete
  • HTTP/S-Wrapper:
    • Can be used for transmissions over http and https
    • Allows arbitrary http methods, e.g. GET, POST, PUT, ...
    • Supported platforms:
      • Windows: using wininet with the standard system configuration
      • Android: using the Apache HttpComponents through JNI
      • Others (Linux, Mac): using the platform-independent Synapse
      • Offline: simulating an internet connection locally for unit tests
    • Supports http, https and socks-Proxy (not on Android)
  • Auto update:
    • Uses a xml format to store the most recent version and a changelog on the server.
    • Supports different updates for 32/64-bit platforms and linux,Windows or BSD systems
    • Checks if a new version is available without downloading the whole, large changelog
    • Allows the execution of an arbitrary command line after the update, runas administrator if necessary
Mercurial repository

Online Documentation

Source on GitHub

Download    (1232 KB) jump to top


This color select dialog is similar to the default one, but has more options:
  • All components of rgb and hls are shown.
  • You can change any component of rgb/hls in a color gradient
  • The selected color component is shown as function depending on the other two components
  • You can change the other two components in a two-dimensional gradient
  • This one is drawn depending on the first component
  • Additional you can enable a list of colors to change
screenshot: examplescreenshot: example

Source on GitHub

Download    (14 KB) jump to top


This is a command line parser working with Delphi as well as with Free Pascal, and on Windows and Linux.
Before you can read the command line arguments, all allowed arguments need to be declared. So the parser can ensure that the user only uses allowed arguments and each given argument has the correct type (e.g. int or string). Furthermore, the parser can automatically generate a help summary displaying all allowed arguments including a description. This again ensures that there are no hidden, undocumented command line arguments.
There are three different versions of the parser. The first two read the arguments from the command line and show the help list of all allowed arguments on stdout or respectively in a message box. The third version (fpc only) runs as cgi service and reads the argument from get/post requests.

Here is a nice comparison between TCommandLineReader and the standard pascal command line functions, when the program is called as executable '" a "'
Windows (Delphi 4)" a "' a '"executable" '" a "'
Windows (fpc 2.6)" a "' a 'executable '" a "'
Linux/bash (fpc 2.6)" a "" a "executable "" a ""
The feature list of rcmdline is:

  • supports linux (--xyz=bar or -x bar) and windows (/) style parameters
  • different input possibilities for boolean flags (-f, --flag, --enable-flag, --disable-flag)
  • understands single (') and double (") quotation marks (even on Windows)
  • type conversion of the string arguments to the declared types
  • automatically user notification about wrong parameters
  • existing files with names containing spaces can be parsed without quotation marks
  • can run as cgi service and answer to GET/POST requests (fpc only)
  • Arguments can be read from: a simple string (e.g. cmdline) or an array of arguments (e.g. paramstr)

Online Documentation

Source on GitHub

Download    (38 KB) jump to top

 Big Decimal Math

2013, 2015
This unit provides a BigDecimal-Typ which stores arbitrary precision (bcd) decimal numbers and can be used like any native numeric type. For example:
  var bd: BigDecimal;
  bd := 12.34;
  bd := bd * 1000 - 42;  // bd = 12298
  bd := bd / 7.0;        // bd = 1756.85714285714286
  bd := StrToBigDecimal('123456789012345678901234567890123456789') + 1; // bd = 123456789012345678901234567890123456790

Summary of features:

  • Supports at least numbers between 10-19327352814 to 1019327352814 with up to 4831838208 decimal digit precision
  • And all standard arithmetic and comparison operators
  • The operators are overloaded, so it can be used like normal numeric types
  • Rounding functions (floor, ceil, to-even, ..)
  • Some more advanced operations, e.g. power and sqrt
  • Also provides exact native float to string conversion functions
  • Written in pure Pascal, therefore platform-independent and without dependencies
  • Designed for correctness and simplicity (rather than speed)

Online Documentation

Source on GitHub

Download    (72 KB) jump to top


This diagram drawing unit follows a model/view concept like qt: There is a view component responsible to show the data, and a model class to store them.
This is more flexible than the traditional way, in which the data is handled within the viewing class.
  • Model/view-concept with automatic synchronization between different views showing the same model
  • Filling with horizontal/vertical color gradient and different line/point-styles
  • Interpolation using linear lines or splines
  • The diagram data can be modified by the user if wanted
  • Multiple axis and point rows as well as a legend naming the latter
  • Automatic calculation of the view range and support for floats
  • Standard models with lists of points, cyclic lists, and a model to merge other ones
  • There is a help file
screenshot: grid likescreenshot: filled

Online Documentation

Source on GitHub

Download    (64 KB) jump to top


These units consist of low-level functions missing in FPC. E.g.:
  • Various array functions (add, delete, search, prealloc, ...)
  • Various string functions (pchar/ansistring, compare, split, search, convert html entities, ...)
  • Various date/time parsing/formatting functions, supporting years before 0 and after 65535, and timezones
  • Stable sorting function for arbitrary sized data arrays (merge+insert sort)
  • Mathematical functions (gcd, primes, Bernoulli statistics,...)
  • Automatic translation of with tr['marked strings'] and components
  • A Pascal template language which is "compiled" to Pascal (similar to the C preprocessor)

Online Documentation

Source on GitHub

Download    (207 KB) jump to top

 Non-VCL Canvas

This package provides a TCanvas replacement which does not depend on the VCL.
The most important features are:
  • Functions to draw texts, ellipses, lines, rectangles and polygones.
  • Functions to copying parts of pictures.
  • Classes to set font, pen and brush properties.
  • An int-int hash map implementation and a resources manager.
In some field they are even better than the functions of Delphi, for example they can draw rotated text.
There is a good, German help, and you could use the documentation of TCanvas from Delphi.

Download    (26 KB) jump to top


You can use this unit to read an Unified Diff, modify its tree structure and save it finally.
  • Reads Unified Diffs of one or many files
  • Creates valid diffs
  • Has functions to remove unnecessary data (see also Simplify Diff)

Download    (3 KB) jump to top


2000, 2003
These are the most important features of TCvirus:
  • It gives you a canvas for direct drawing on the screen.
  • It can mirror the screen.
  • It returns handles of important objects like the task button, the task list, and the desktop.
  • It can hide your program from the task manager (on Win9x).
  • It can open and close the CD tray.
Because TCvirus has originally been a component, there are 2 units, a component for the VCL and a unit for non VCL.

Download    (60 KB) jump to top


This allows an automatical update about the internt.
To use the class you need a wininet unit containing the windows internet functions (above is a new class which uses a better customizable xml format).
  • check for new versions
  • download them in a compressed zip archive
  • extract this
  • replace the current executable with the new one on every Windows
  • detect missing access rights on Windows NT...

Download    (9 KB) jump to top


This is a small browser based on the IE.
It is completely useless for a normal user, but you can use it to implement a browser for a certain web page in your program. The appearance and behavior can be controlled over command line switches, so it allows for example restricted access.

Download    (188 KB) jump to top


This unit can (de-)compress strings with the Huffman algorithm. After compression frequently occurring characters are stored with less than 8 bit.
It is also possible to compress Unicode strings, arrays and files, by treating them as byte strings.
This unit contains a copy of TBits from the 32-Bit VCL, which only works on 32 systems. On other platforms the normal VCL can be used by enabling a define.
You get the best compression rates in data which contains many repeated characters, but it is usually worse than modern compressions like ACE or RAR.

Download    (12 KB) jump to top
For G+ authorship:
Personal home page of