Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
About The Best Formula In The World
Architecture details
Benchmarks
Books
By Reference Argument Passing
Compatibility between versions
Creating And Using Libraries
Database Datatype Mapping
Database Request Quoting
Date & time management
Dates and calendars
DBus and Gambas
Differences Between Shell And Exec
Differences From Visual Basic
Distributions & Operating Systems
Drag & Drop
DrawingArea Internal Behaviour
External functions datatype mapping
Frequently Asked Questions
Gambas Farm Server Protocol
Gambas Mailing List Netiquette
Gambas Markdown Syntax
Gambas Naming Conventions
Gambas Object Model
Gambas Scripting
Gambas Server Pages
Gambas Unit Testing
Gambas Wiki Markup Syntax
Getting Started With Gambas
Hall Of Fame
Housekeeping, cleaning up
Image Management In Gambas
Including Help Comments in Source Code
Interpreter limits
Introduction
Just In Time Compiler
Just In Time Compiler (old version)
License
Localisation and Internationalization
Mailing Lists & Forums
Naming Conventions
Network Programming
ODBC Component Documentation
PCRE Pattern Syntax
Porting from Gambas 2 to Gambas 3
Previous News
Project Directory Structure
Release Notes
Reporting a problem, a bug or a crash
Rich Text Syntax
Screenshots
Text highlighting definition file syntax
The Program has stopped unexpectedly by raising signal #11
Variable Naming Convention
WebPage Syntax
Web site home page
What Is Gambas?
Window & Form Management
Window Activation & Deactivation
Window Life Cycle
XML APIs
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Gambas Server Pages

In Gambas, you have some sort of scripter hack that allows you to write ASP-like files that I named " server pages".

Put that in a text file, make it executable, and run it.

#!/usr/bin/env gbw3
<%
DIM sEnv AS String
%>

<!-- Variable declaration must come before any HTML -->

<html>

<h2>CGI script environmental variables</h2>

<table border="1" cellspacing="0" cellpadding="2">

  <tr>
    <th align="left">Name</th>
    <th align="left">Value</th>
  </tr>

<% FOR EACH sEnv IN Application.Env %>
  <tr valign="top">
    <td><%= sEnv %></td>
    <td><%= Application.Env[sEnv] %>&nbsp;</td>
  </tr>
<% NEXT %>

</table>

</html>

As you can see, the server page is a script, but the script executable is 'gbw3', not 'gbs3'.

'gbw3' is actually a symbolic link to 'gbs3'. When 'gbs3' detects than it is run from the 'gbw3' symbolic link, it knows that it will have to process a server page and not a script. Then 'gbs3' will transform the server page into...a normal script, and will execute it.

Except the initial line with the '#!/usr/bin/env gbw3' magic, the syntax is very similar to ASP pages.

  • <% XXX %> introduces any Gambas code.

  • <%= XXX %> evaluates a Gambas expression, translates it into HTML, and inserts the html inline.

Note that the gb.web component is used by default. So you can use the Session object, the Response object, the Request object, and so on.

These Gambas server pages are CGI scripts, and must be managed as any other script in your preferred web server.

This feature is experimental. Please report any problem you could have with it!

Using extra components

To use other components, server pages implement a special instruction named USE:

USE "_component name_"

That instruction loads a component as when it is checked in the component tab of the project properties dialog in the IDE.

Note that the component name must be specified as a string, i.e. between quotes.

See Also