ScriptBasic => Download => Topic started by: Support on April 21, 2008, 09:36:18 am

Title: ScriptBasic 2.1 Beta for Windows - SETUP (Reference Only - Use current source)
Post by: Support on April 21, 2008, 09:36:18 am
This zip file contains the Windows 2.1 setup built by Peter Verhas. The 2.1 version of ScriptBasic was never officially released by Peter. There have been a couple changes since the setup.exe and cab file were built. I have included an updates directory that contains the application server (sbhttpd.exe) and MySQL extension module. (mysql.dll)  Replace the installed version with these updated copies.

ScriptBasic 2.1.1 for Windows (  

Note: The setup dialog will indicate that the version being installed is 2.0 which is incorrect. (scriba -v will show 2.1 for the interpreter)

Extension Module Summary
These modules require external libraries that may need to be installed for the extension module to work. All other modules have static linked the libraries as part of the extension module.

Building multi-platform GUI applications with GTK and ScriptBasic

( (

What is GTK+?

GTK+ is a highly usable, feature rich toolkit for creating graphical user interfaces which boasts cross platform compatibility and an easy to use API. GTK+ it is written in C, but has bindings to many other popular programming languages such as C++, Python and C# among others. GTK+ is licensed under the GNU LGPL 2.1 allowing development of both free and proprietary software with GTK+ without any license fees or royalties.


GTK+ has been developed for over a decade to be able to deliver the enticing features and superb performance that it brings to your application development. GTK+ is supported by a large community of developers and has core maintainers from companies such as Red Hat, Novell, Imendio and Opened Hand.

Cross Platform

Originally GTK+ was developed for X Windows but it has grown over the years to include backend support for other well known windowing systems. Today you can use GTK+ on:
I have assembled into one zip (8 MB) everything you need for GTK development with ScriptBasic.
Download GTK for Windows (
Title: GTK Installation Tips
Post by: Support on April 22, 2008, 01:45:32 am
The following tips will help you get your GTK development environment going from the bundled zip provided in the previous post.

1. The first step is to run the gtk-2.12.9-win32-2.exe GTK+ runtime installer. Once this is completed you can run the demo provided from the Windows start menu.

Widget Gallery (
GTK+ Reference Manual (

2. Next we are going to install the Glade 3 GUI designer. Unzip the file into your C:\GTK directory. This will overlay the sub-directory structure already in place created with step 1. You will need to create a short-cut on your desktop manually with the C:\GTK\bin\glade-3.exe program.

( Screen Shots (

3. In this step we are going to update the libglade files with the most recent versions. Unzip the file into your C:\GTK\bin directory.

ScriptBasic GTK Glade Example

Code: [Select]

' Glade Hello World

' GTK Interface
include gtk.bas

' Initialize GTK & Glade
gtk_init("NULL", "NULL")

' Load and show Glade defined window
xml = glade_xml_new("")

' Get window ID and define window close event
win = glade_xml_get_widget(xml, "window1")
gtk_server_connect(win, "delete-event", "window")

' Event Handler
    this_event = gtk_server_callback("WAIT")
UNTIL this_event = "window"


Glade XML Project File
Code: [Select]

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "">


<widget class="GtkWindow" id="window1">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Hello</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="default_width">400</property>
  <property name="default_height">350</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="decorated">True</property>
  <property name="skip_taskbar_hint">False</property>
  <property name="skip_pager_hint">False</property>
  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
  <property name="focus_on_map">True</property>
  <property name="urgency_hint">False</property>

    <widget class="GtkFixed" id="fixed1">
      <property name="visible">True</property>

   <widget class="GtkLabel" id="label1">
     <property name="width_request">122</property>
     <property name="height_request">17</property>
     <property name="visible">True</property>
     <property name="label" translatable="yes">Hello World !</property>
     <property name="use_underline">False</property>
     <property name="use_markup">False</property>
     <property name="justify">GTK_JUSTIFY_LEFT</property>
     <property name="wrap">False</property>
     <property name="selectable">False</property>
     <property name="xalign">0.5</property>
     <property name="yalign">0.5</property>
     <property name="xpad">0</property>
     <property name="ypad">0</property>
     <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
     <property name="width_chars">-1</property>
     <property name="single_line_mode">False</property>
     <property name="angle">0</property>
     <property name="x">128</property>
     <property name="y">128</property>


4. Finally we are going to install GTK-server which is the interface for ScriptBasic to use GTK.

A. Run the gtk-server-2.2.3-installer.exe program.
B. Copy the C:\GTK-server\Modules\Scriptbasic\gtk-server.dll to the C:\scripbasic\modules directory.
C. Copy the C:\GTK-server\Modules\Scriptbasic\gtk.bas file to the C:\scripbasic\include directory.
D. Copy the C:\GTK-server\Modules\Scriptbasic\*.sb ScriptBasic programs to the C:\scripbasic\examples diectory. Note that there is a from the ScriptBasic install that should be renamed prior to the copy.

The final step is to add the GTK_SERVER_CONFIG=C:\GTK-server\gtk-server.cfg environment variable. This is done via your Windows control panel --> System --> Advanced --> Environment Variables button.

REBOOT to have the changes take affect.

You should now be able to run the ScriptBasic GTK examples.

Peter's ( GTK ScriptBasic example. (Windows)

Title: XAMPP for Windows
Post by: Support on April 22, 2008, 02:08:00 am

The fastest way to install MySQL, phpMyAdmin, PHP and Apache with an easy to administer control panel is to install XAMPP for Windows (


Download Installer (

I will be using this install method to interface with the ScriptBasic extensions and application server. This will give you a local web server and MySQL database to develop with.
Title: Testing Apache with ScriptBasic
Post by: Support on April 22, 2008, 07:33:50 am
The next step in our setup process is to test if ScriptBasic (scriba.exe) can be used for CGI programming. The following echo.bas ScriptBasic CGI program will display the POST/GET header and environment variables by running itself.

Copy this program and place it in your C:\xampp\cgi-bin directory.
Code: [Select]

#!C:/scriptbasic/bin/scriba.exe -c
global const nl = "\n"
Const NumberOfCookies = 3

include cgi.bas

option cgi$Method cgi::Get or cgi::Upload

' cgi::RequestBasicAuthentication "login password"
cgi::Header 200,"text/html"

' We are setting several cookies. The expiry time is ten seconds so you can test that
' the cookies are sent by the browser if you press some of the buttons fast enough,
' but it does not if you are slow
for i=1 to NumberOfCookies
  ' cookie(i) is i, no domain is defined, path is /, expires after 10 seconds, not secure
  cgi::SetCookie "cookie" & i,i,undef,"/",gmtime()+10,false
next i


print """<HTML>
<title>CGI parameter testing</title>
<BODY><font face="VERDANA" size="2">
<H1>View CGI Parameters</H1>
This page shows the cgi parameters the way it was uploaded.
<!-- here is the result of the previous HTTP request -->

CGI system variables


print "ServerSoftware  = ",cgi::ServerSoftware(), nl
print "ServerName      = ",cgi::ServerName(), nl
print "GatewayInterface= ",cgi::GatewayInterface(),nl
print "ServerProtocol  = ",cgi::ServerProtocol(), nl
print "ServerPort      = ",cgi::ServerPort(), nl
print "RequestMethod   = ",cgi::RequestMethod(), nl
print "PathInfo        = ",cgi::PathInfo(), nl
print "PathTranslated  = ",cgi::PathTranslated(), nl
print "ScriptName      = ",cgi::ScriptName(), nl
print "QueryString     = ",cgi::QueryString(), nl
print "RemoteHost      = ",cgi::RemoteHost(), nl
print "RemoteAddress   = ",cgi::RemoteAddress(), nl
print "AuthType        = ",cgi::AuthType(), nl
print "RemoteUser      = ",cgi::RemoteUser(), nl
print "RemoteIdent     = ",cgi::RemoteIdent(), nl
print "ContentType     = ",cgi::ContentType(), nl
print "ContentLength   = ",cgi::ContentLength(), nl
print "UserAgent       = ",cgi::UserAgent(), nl
print "Cookie          = ",cgi::RawCookie(), nl

print "Referer         = ",cgi::Referer(),nl
print "Password        = ",Environ("HTTP_PASSWORD"),nl
print "Full auth string= ",Environ("HTTP_AUTHORIZATION"),nl
print "\nCookies:\n"
for i=1 to NumberOfCookies
  print "cookie" & i," ",cgi::Cookie("cookie" & i),"\n"
next i

print "Text field using Param(\"TEXT-FIELD\") is ",cgi::Param("TEXT-FIELD"),nl,nl

if cgi::RequestMethod() = "GET" then
  print "GET text field using GetParam(\"TEXT-FIELD\") is ",cgi::GetParam("TEXT-FIELD"),nl
end if

if cgi::RequestMethod() = "POST" then
  print "POST text field using PostParam(\"TEXT-FIELD\") is ",cgi::PostParam("TEXT-FIELD"),nl
  if cgi::ContentType() like "multipart*" then
    print "Original file name is ",cgi::FileName("FILE-UPLOAD-NAME"),nl
    if cgi::FileLength("FILE-UPLOAD-NAME") > 0 then
      print "File of length ",cgi::FileLength("FILE-UPLOAD-NAME")," bytes is saved\n"
      on error goto NoSave
      cgi::SaveFile "FILE-UPLOAD-NAME",""
      print "There is no uploaded file."
    end if
  end if
end if

A simple form to POST parameters:<BR>
<FORM METHOD="POST" ACTION="/cgi-bin/echo.bas">
</PRE></TD><TD BORDER=1 width="20">&nbsp;</TD><TD BORDER=0 BGCOLOR="EEEEEE"><PRE>
A simple form to GET parameters:<BR>
<FORM METHOD="GET" ACTION="/cgi-bin/echo.bas">
A simple form to UPLOAD a file:<BR>
<FORM METHOD="POST" ACTION="/cgi-bin/echo.bas" ENCTYPE="multipart/form-data">

print "An error has happened saving the file. Code =",error(),nl

resume next

This is what the output should look like after a post.

Title: MySQL Testing
Post by: Support on April 23, 2008, 07:47:13 am
I guess this would be a good time to test the MySQL XAMPP install with ScriptBasic. XAMPP installed a demo CD Collection MySQL database that is used in this example.


Database: cdcol - Table: cds

Code: [Select]


INCLUDE mysql.bas

dbh = mysql::RealConnect("localhost","root","","cdcol")
mysql::query(dbh,"SELECT * FROM cds")

WHILE mysql::FetchHash(dbh,flds)
  PRINT flds{"titel"} & " | " & flds{"interpret"} & " | " & flds{"jahr"} & " | " & flds{"id"} & "\n"



Code: [Select]

Beauty | Ryuichi Sakamoto | 1990 | 1
Goodbye Country (Hello Nightclub) | Groove Armada | 2001 | 4
Glee | Bran Van 3000 | 1997 | 5


Note: While the above code is a simple way to dump a table to the console, in a production environment you would want to use the mysql::Connect("Accounting") method. "Accounting" is a name you assign in the scriba.conf to a MySQL definition key.
Code: [Select]

mysql (
  connections (
    Accounting ( ; the name of the connection
 host "" ; the host for the connection
 db "ABC" ; database for the connection
 user "accountant" ; user for the connection
 password "PostIt" ; password for the connection
 port 0 ; the port to use
 socket "" ; the name of the socket or ""
 flag 0 ; the client flag
 clients 10 ; how many clients to serve before really closing the connections

The mysql::FetchHash() function is a nice feature using ScriptBasic's associative arrays when working with one table. This makes your code more readable when referring to columns by name. When using joins or other complex SQL statements, you can use the mysql::FetchArray() function to load the result set row into a normal array.


Don't forget to copy the mysql.dll from the updates directory that was included in the ScriptBasic install zip and replace C:\scriptbasic\modules\mysql.dll with the updated version.
Title: ScriptBasic Application Server Install
Post by: Support on April 24, 2008, 05:36:08 am
In this post I will show how to install the ScriptBasic application server. (sbhttpd.exe) Just like scriba.exe, the sbhttpd.exe application server uses the scriba.conf file for it's configuration. The file is in a binary format created with the scriba -k option. For this demonstration, we are going to use a minimal server configuration and add other options later.

The first step is to save a text copy of the current scriba.conf file. This is done using the following console mode command in the C:\scriptbasic\bin directory.

scriba -D >

Copy the below configuration to a scriba.conf.txt file in your C:\scriptbasic\bin directory. We need to convert this text version of scriba.conf to it's needed binary form.

scriba -k scriba.conf.txt

This will create a new binary scriba.conf file that ScriptBasic needs.
Code: [Select]

dll ".dll"
module "c:\\scriptbasic\\modules\\"
include "c:\\scriptbasic\\include\\"
docu "c:\\scriptbasic\\doc\\"
maxinclude 100
maxstep 0
maxlocalstep 0
maxlevel 3000
maxmem 0
servers (
  server (
    port 8080
    ip ""
    protocol "http"
  threads 20
  listenbacklog 3
  home "C:\\xampp\\htdocs\\app-bin\\"
  proxyip 1
  pid (
    file "c:\\scriptbasic\\httpdlog\\pid.txt"
    delay 10
    wait (
      period 10
      length 1
  vdirs (
    dir "/util/:c:\\scriptbasic\\web\\"
  errmsgdest 3
  nolog 0
  log (
    panic (
      file "c:\\scriptbasic\\httpdlog\\panic.log"
    app (
      file "c:\\scriptbasic\\httpdlog\\app.log"
    err (
      file "c:\\scriptbasic\\httpdlog\\err.log"
    hit (
      file "c:\\scriptbasic\\httpdlog\\hit.log"
    stat (
      file "c:\\scriptbasic\\httpdlog\\stat.log"
  msg404 """
<TITLE>Error 404 page not found</TITLE>
<FONT FACE=\"Verdana\" SIZE=\"2\">
<H1>Page not found</H1>
We regretfully inform you that the page you have requested can not be found on this server.
In case you are sure that this is a server configuration error, please contact
<FONT SIZE=\"3\"><TT>root@localhost</TT></FONT>
  code404 "200 OK"

Create a C:\xampp\htdocs\app-bin directory as a 'stub' for the proxy to ScriptBasic.

Create a C:\scriptbasic\web directory and copy the C:\xampp\cgi-bin\echo.bas into this directory. You will need to edit the three references to "/cgi-bin/echo.bas" in the form section and change it to "/app-bin/util/echo.bas". This allows mapping your web apps outside the Apache web root for an extra level of security.

To install the ScriptBasic application server as a NT service, type the following  command.

sbhttpd -install


Setting the sbhttpd to automatic will start the server at boot time. Use the Windows services feature to start/stop the server if changes to the scriba.conf are made.

Next we need to modify the Apache C:\xampp\apache\conf\httpd.conf file to add the proxy support for ScriptBasic.

Enable the following Apache modules by removing the "#" character at the beginning of the line.

LoadModule proxy_module modules/
LoadModule proxy_http_module modules/

Add the following lines to httpd.conf file to configure the ScriptBasic application server as a proxy server. All URL requests made to the /app-bin (and it's virtual assigned directories) will be forwarded to sbhttpd.exe for processing.

ProxyRequests Off
ProxyPass /app-bin/
ProxyPassReverse /app-bin/

Save the file and restart the Apache web server for the changes to take affect.

The following browser screen shot shows echo.bas running on the application server rather then a CGI program on Apache.


The next post will cover how to use the MT extension for in memory session support.