Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Support

Pages: 1 ... 56 57 [58] 59
856
General Discussions / Embedding into application
« on: May 14, 2006, 10:03:48 AM »
Bill,

I haven't gotten into the embedding ScriptBasic but I'll try to help. My first question is where is the HTML coming from? Is this a CGI application? Can you provide more details to what your trying to do?

John

857
General Discussions / ScriptBasic Wiki Active
« on: April 15, 2006, 06:16:13 PM »
ScriptBasic now has a wiki for the documentation project. We are using the MediaWiki open source product that also powers the Wikipedia project.

WIKI

If your able to help with the conversion of the user guide Peter did in HTML to wiki format, it would be much appreciated.

858
Welcome aboard !

I would start out working with the Windows version playing with the programs provided in the source distribution. Then try your hand at creating a CGI script or two.

The docs should answer most of your questions about the language but if you need help, post a request here on the forum.

The ScriptBasic HTTP application server is sure to put a smile on your face and give you more time to do other things in life besides programming.  :?

859
I'm looking for Apache users (Windows & Linux) that would like to beta test a new release of the ScriptBasic Application Server. (sbhttpd) This allows you to run your ScriptBasic CGI apps in a multi-threaded environment with session support and keep connected to your MySQL database between submits. When interfaced to Apache via the rewrite & proxy modules, all dynamic content request are executed by the ScriptBasic Application Server in a secure manor behind the Apache web server.

John
support AT scriptbasic DOT org

860
What's New / ScriptBasic Features
« on: April 09, 2006, 07:30:57 PM »

  • Open source LGPL project
  • Multi-platform (Windows, Linux, Unix, OSX, ...)
  • Basic command line interpreter, multi-threaded HTTP application server and application script engine embedding
  • Extension module API (CGI, MySQL, ODBC, Berkeley DB, GTK, Curl, ...)
  • Basic interpreter - text and binary source file with optional caching
  • Standalone executables - binds interpreter to program (win/*nix)
  • Output programs as C source to be linked with ScriptBasic runtime library and user modules
  • Name space support
  • Relaxed / auto variable typing (forget DIM and think undef)
  • TYPE, ISARRAY, ISSTRING, ISINTEGER, ISREAL, ISNUMERIC, ISDEF, ISUNDEF, ISEMPTY
  • Associative arrays (reference elements by name - MySQL & ODBC modules assign columns to named arrays)
  • Standard branching syntax (GOTO, GOSUB/RETURN, FOR/NEXT, DO/WHILE/UNTIL, REPEAT/UNTIL, CALL)
  • Multi-function IO directives ([liNE] INPUT, PRINT, OPEN - files, ports, standard IO)
  • Time/Date formatting and math
  • Extended string functions (REPLACE, SPLIT, SPLITA)

Syntax by example

861
General Discussions / ScriptBasic Author
« on: April 09, 2006, 03:27:53 PM »
Peter Verhas is the author of ScriptBasic and lead developer/consultant for the ScriptBasic LGPL open source project.

862
Download / ScriptBasic 2.0b0 Downloads
« on: April 09, 2006, 03:45:33 AM »
Linux / Unix
  scriba-v2.0b0-source.tar.gz Linux / Unix Source
scriba-2.0b0-1.i386.rpm Linux RPM

Windows
scriba-v2.0b0-source.zip Windows Source & Documentation
scriba-v2.0b0-bin.zip Windows Binaries & Documentation
scriba-v2.0b0-exe.zip Windows SETUP (wthout documentation)

Documentation
html-v2.0b0.zip Full Documentation Set (.HTML)
chm-v2.0b0.zip Full Documentation Set (.CHM)
text-v2.0b0.zip Full Documentation Set (TEXI)

Examples
samplebas.tgz Examples Extracted From Documentation

Note:  The Windows & *nix source distributions are identical except for how source file lines are terminated and how they are packaged. A convert.pl utility is included to convert the Windows version to compile under *nix.

863
Source / ScriptBasic Developer Guide
« on: April 09, 2006, 12:30:37 AM »
I have transfered the online ScriptBasic Developer Guide from the
ScriptBasic.com site and will converting it to the wiki on the ScriptBasic.org site.

Developer Guide

Doxygen Developer Guide


John

864
General Discussions / ScriptBasic User Guide
« on: April 09, 2006, 12:17:12 AM »
I have transfered the online ScriptBasic User Guide from the
ScriptBasic.com site and will be converting it to the wiki on the ScriptBasic.org site.

User Guide

Sarian Systems - ScriptBasic Reference Guide (enhanced docs)

Note Please use the Serian user guide as a general reference as they have customised the language and may have imposed limitations that don't exist in the distributed version of the language.

John

865
Berkeley DB / Berkeley DB Overview
« on: April 01, 2006, 07:05:19 PM »
DISCONTINUED support in ScriptBasic 3.0

Berkely DB

Berkeley DB is a database engine that provides developers with fast, reliable, local persistence with zero administration. Berkeley DB is a library that links directly into your application. Your application makes simple function calls, rather than sending messages to a remote server, eliminating the performance penalty of client-server architectures. Berkeley DB stores data in application native format, as simple key/value pairs, eliminating the need for translation or mapping. Berkeley DB eliminates the overhead of SQL query processing, enabling applications with predictable access patterns to run faster. Berkeley DB is the ideal choice for static queries over dynamic data, while traditional relational databases are well suited for dynamic queries over static data.

Berkeley DB delivers the same robust data storage features as traditional, relational database systems, such as ACID transactions and recovery; locking, multiple processes and multi-threading for high concurrency; hot and cold backup; and single-master replication for high availability applications. Berkeley DB can manage databases in memory, on disk or both. Berkeley DB is designed to run in a completely unattended fashion, so all runtime administration is programmatically controlled by the application, not by a human administrator. It has been designed to be simple, fast, small and reliable.

Berkeley DB supports replication over multiple systems, enabling applications to scale massively with low latency and provide fault tolerance for high availability solutions. This technique works by having all updates go to a designated master, which distributes changes automatically to a set of replicas. The read workload can be spread across the replicas, and new replicas can join the group at any time to scale the system. If any replica fails, the remaining replicas can take over for it. If the master fails, the application can call for an election or simply designate a new master. Once the new master has been chosen, all of the replicas synchronize with the new master and move forward with normal processing with no interruption in service.

Berkeley DB is very flexible and puts developers in control of many aspects of its behavior, which allows it to be used across a wide range of applications and as a replacement for custom, home-grown solutions. For example, developers can control how resources are allocated, the amount of memory dedicated to caching records, the on-disk storage structure used for individual tables, durability and isolation guarantees, and replication policies. It includes full source code for easier porting, integration, debugging and optimization.

Berkeley DB provides very fast, reliable and scalable persistence for applications that need to store data locally, run unattended without interruption, and access data in a predictable fashion.



Open - opens a database and returns a handle
       Type - Btree, Hash, Recno, Queue, Unknown
       Flags - Create, NoMap, RdOnly, Thread, Trunc

       DB = bdb::Open(DataBase,type,flags,unixmode)


Close - closes a database

       bdb::Close(DB)


Put - put a key-value pair into the database
      Append - use with Recno databases
      NoOverWrite - error if record exists

      bdb::Put(DB,key,value,flag)


Get - get the value associated with the key

      value = bdb::Get(DB,key)


First - retrieves the first key/value pair or first match if a key (full/partial) is given

        value = bdb::First(DB,key)
        bdb::First(DB,key)



Last - position the cursor to the last record and return the value if required

       value = bdb::Last(DB)
       bdb::Last(DB)



Next - returns next record value - returns undef if cursor not set or at end of file

       value = bdb::Next(DB)


Previous - returns previous record value - returns undef if cursor not set or at begininng of file

           value = bdb::Previous(DB)


Key - return the key of the last accessed record

      key = bdb::Key(DB)


Update - updates the value of the last accessed record

         bdb::Update(DB,value)


DeleteRecord - deletes the last accessed record

               bdb::DeleteRecord(DB)


DeleteAll - deletes all records with the given key

            bdb::DeleteAll(DB,key)


BeginTransaction

This command starts a transaction. This transaction lasts until a CommitTransaction, EndTrasaction, AbortTransaction command is executed or the execution of the BASIC program is finished. Any transaction not finished using CommitTransaction or EndTransactionis aborted.

Transactions provide database integrity. Operations accessing the database in a transaction get exclusive access to the records they are accessing. When a program reads a record in a transaction the module assumes that the program wants to alter the value of the record later and does not allow any other program to read the value until the transaction is finished.

When a program tries to access a locked record the program execution is suspended until the record is unlocked. If there are more programs waiting for the same record one of them gets access to the record and the others remain waiting.

When a program alters some data in a transaction either all alterations are done in a single transaction or none of the alterations are performed.

bdb::BeginTransaction


CommitTransaction

This command commits the transaction started using the command bdb::BeginTransaction. When this command is executed all the alterations are done on the database that the program performed since the transaction begin and all locks are released, so other programs may get access to the records.

bdb::CommitTransaction


EndTransaction - calls bdb::CommitTransaction - added for syntax compatibility

bdb::EndTransaction


AbortTransaction

This command aborts a transaction. This means that the alterations performed during the transaction are not performed and the locked records are released. This command is automatically executed when a database with an active transaction is closed or when the interpreter finishes the program execution and the database remained unclosed with an open transaction.

bdb::AbortTransaction


Drop

This command deletes a database. The name of the database should be specified. Whenever you want to delete a database programmatically use this command instead of deleting the database file directly. This command takes care of the configuration and should be more compatible with future releases of the module than just deleting the physical file.

bdb::Drop("databasename")

Code: [Select]
INCLUDE bdb.bas

db = bdb::Open("test.db",bdb::BTree,bdb::Create,0)

bdb::BeginTransaction
PRINT "Transaction Started\n"
counter = bdb::Get(db,"COUNTER")
PRINT "Counter is ",counter,"\n"

IF IsDefined(counter) THEN
  counter = counter + 1
  bdb::Update(db,counter)
  print "Record Updated\n "
ELSE
  counter = 1
  bdb::Put(DB,"COUNTER",counter)
  PRINT "Record Created\n "
END IF
bdb::EndTransaction
PRINT "Transaction Completed\n"

bdb::Close(db)

' bdb::Drop("test.db")

END
Original Berkeley DB Documentation

866
Installation / Windows Apache and CGI
« on: March 27, 2006, 09:54:40 PM »
You need to make a few changes to get ScriptBasic to run as a CGI program under Apache for Windows.

httpd.conf

# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler cgi-script .cgi .bas  (or whatever you would like to use as an attribute)

# First, we configure the "default" to be a very restrictive set of
# features.  
#
<Directory />
    Options FollowSymLinks +ExecCGI
    AllowOverride None
</Directory>

The first line of your script should look something like this.

#!G:/ScriptBasic/bin/scriba.exe -c

867
ScriptBasic Examples w/source / GTK - Glade XML Project File Example
« on: March 26, 2006, 09:05:44 PM »
Here is an example of using GTK and the Glade GUI designer project file with  ScriptBasic.

Code: [Select]

' Glade XML Demo

' GTK Interface
include gtk.bas

include cio.bas
cio::detach()


' GTK Interface Function
FUNCTION GUI(g0, g1, g2, g3, g4, g5, g6, g7, g8, g9)
LOCAL gtk_cmd
gtk_cmd = STR(g0) & " " & STR(g1) & " " & STR(g2) & " " & STR(g3) & " " & STR(g4) & " " & STR(g5) & " " & STR(g6) & " " & STR(g7) & " " & STR(g8) & " " & STR(g9)
GUI = GTK::gtk(gtk_cmd)
END FUNCTION

' Load GTK Function DEF's
GUI("g:\\gtk-server\\gtk-server.cfg")

' Enable GTK Logging
' GUI("gtk_server_logging", 1)

' Create GUI
xml = GUI("gtk_server_glade_file", "G:\\sb\\examples\\gtk\\glade_gui.xml")
win = GUI("gtk_server_glade_widget", "window")
GUI("gtk_server_connect", win , "destroy", "exit")
quitbtn = GUI("gtk_server_glade_widget", "QuitButton")
GUI("gtk_server_connect", quitbtn, "clicked", "quit")


' Event Handler
REPEAT
event = GUI("gtk_server_callback", "WAIT")
UNTIL event = "exit" OR event = "quit"


' End Program
GUI("g_object_unref", xml)
GUI("gtk_exit", 0)

END

Linux


Linux


Windows


Windows


Glade XML Project File
Code: [Select]

<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkWindow" id="window">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Preferences</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <signal name="delete_event" handler="on_window1_destroy"/>

  <child>
    <widget class="GtkVBox" id="AllDaGoodies">
      <property name="border_width">6</property>
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">0</property>

      <child>
   <widget class="GtkNotebook" id="Preferences">
     <property name="visible">True</property>
     <property name="can_focus">True</property>
     <property name="show_tabs">True</property>
     <property name="show_border">True</property>
     <property name="tab_pos">GTK_POS_TOP</property>
     <property name="scrollable">False</property>
     <property name="enable_popup">False</property>

     <child>
       <widget class="GtkVBox" id="LocationOptions">
         <property name="border_width">6</property>
         <property name="visible">True</property>
         <property name="homogeneous">False</property>
         <property name="spacing">0</property>

         <child>
      <widget class="GtkRadioButton" id="Here">
        <property name="visible">True</property>
        <property name="can_focus">True</property>
        <property name="label" translatable="yes">_Here</property>
        <property name="use_underline">True</property>
        <property name="relief">GTK_RELIEF_NORMAL</property>
        <property name="active">False</property>
        <property name="inconsistent">False</property>
        <property name="draw_indicator">True</property>
      </widget>
      <packing>
        <property name="padding">0</property>
        <property name="expand">False</property>
        <property name="fill">False</property>
      </packing>
         </child>

         <child>
      <widget class="GtkRadioButton" id="There">
        <property name="visible">True</property>
        <property name="can_focus">True</property>
        <property name="label" translatable="yes">_There</property>
        <property name="use_underline">True</property>
        <property name="relief">GTK_RELIEF_NORMAL</property>
        <property name="active">False</property>
        <property name="inconsistent">False</property>
        <property name="draw_indicator">True</property>
        <property name="group">Here</property>
      </widget>
      <packing>
        <property name="padding">0</property>
        <property name="expand">False</property>
        <property name="fill">False</property>
      </packing>
         </child>
         <child>
      <widget class="GtkButton" id="HelloButton">
        <property name="visible">True</property>
        <property name="can_default">True</property>
        <property name="can_focus">True</property>
        <property name="label">Hello</property>
        <property name="use_stock">True</property>
        <property name="relief">GTK_RELIEF_NORMAL</property>
                  <signal name="clicked" handler="on_button1_clicked"/>
      </widget>
         </child>

       </widget>
       <packing>
         <property name="tab_expand">False</property>
         <property name="tab_fill">True</property>
       </packing>
     </child>

     <child>
       <widget class="GtkLabel" id="LocationLabel">
         <property name="visible">True</property>
         <property name="label" translatable="yes">Location</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>
       </widget>
       <packing>
         <property name="type">tab</property>
       </packing>
     </child>

     <child>
       <widget class="GtkColorSelection" id="ColorSelection">
         <property name="border_width">6</property>
         <property name="visible">True</property>
         <property name="has_opacity_control">True</property>
         <property name="has_palette">False</property>
       </widget>
       <packing>
         <property name="tab_expand">False</property>
         <property name="tab_fill">True</property>
       </packing>
     </child>

     <child>
       <widget class="GtkLabel" id="ColorLabel">
         <property name="visible">True</property>
         <property name="label" translatable="yes">Color</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>
       </widget>
       <packing>
         <property name="type">tab</property>
       </packing>
     </child>

     <child>
       <widget class="GtkFontSelection" id="FontSelection">
         <property name="border_width">6</property>
         <property name="visible">True</property>
         <property name="preview_text" translatable="yes">abcdefghijk ABCDEFGHIJK</property>
       </widget>
       <packing>
         <property name="tab_expand">False</property>
         <property name="tab_fill">True</property>
       </packing>
     </child>

     <child>
       <widget class="GtkLabel" id="FontLabel">
         <property name="visible">True</property>
         <property name="label" translatable="yes">Font</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>
       </widget>
       <packing>
         <property name="type">tab</property>
       </packing>
     </child>

      <child>
        <widget class="GtkScrolledWindow" id="scrolledwindow1">
          <property name="visible">True</property>
          <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
          <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
          <property name="shadow_type">GTK_SHADOW_IN</property>
          <property name="window_placement">GTK_CORNER_TOP_LEFT</property>

          <child>
            <widget class="GtkTextView" id="text1">
              <property name="visible">True</property>
              <property name="can_focus">True</property>
              <property name="editable">True</property>
              <property name="justification">GTK_JUSTIFY_LEFT</property>
              <property name="wrap_mode">GTK_WRAP_WORD</property>
              <property name="cursor_visible">True</property>
              <property name="pixels_above_lines">0</property>
              <property name="pixels_below_lines">0</property>
              <property name="pixels_inside_wrap">0</property>
              <property name="left_margin">0</property>
              <property name="right_margin">0</property>
              <property name="indent">0</property>
              <property name="text" translatable="yes"></property>
            </widget>
          </child>
        </widget>
        <packing>
          <property name="padding">0</property>
          <property name="expand">True</property>
          <property name="fill">True</property>
        </packing>
      </child>

      <child>
        <widget class="GtkLabel" id="EditLabel">
          <property name="visible">True</property>
          <property name="label" translatable="yes">Edit</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>
        </widget>
        <packing>
          <property name="type">tab</property>
        </packing>
      </child>


   </widget>
   <packing>
     <property name="padding">0</property>
     <property name="expand">True</property>
     <property name="fill">True</property>
   </packing>
      </child>

      <child>
   <widget class="GtkVBox" id="TheGlobalButtonArea">
     <property name="visible">True</property>
     <property name="homogeneous">False</property>
     <property name="spacing">0</property>

     <child>
       <widget class="GtkHSeparator" id="hseparator1">
         <property name="visible">True</property>
       </widget>
       <packing>
         <property name="padding">0</property>
         <property name="expand">False</property>
         <property name="fill">False</property>
       </packing>
     </child>

     <child>
       <widget class="GtkHButtonBox" id="hbuttonbox2">
         <property name="visible">True</property>
         <property name="layout_style">GTK_BUTTONBOX_END</property>
         <property name="spacing">0</property>

         <child>
      <widget class="GtkButton" id="QuitButton">
        <property name="visible">True</property>
        <property name="can_default">True</property>
        <property name="can_focus">True</property>
        <property name="label">gtk-quit</property>
        <property name="use_stock">True</property>
        <property name="relief">GTK_RELIEF_NORMAL</property>
                  <signal name="clicked" handler="on_window1_destroy"/>
      </widget>
         </child>
       </widget>
       <packing>
         <property name="padding">0</property>
         <property name="expand">False</property>
         <property name="fill">False</property>
       </packing>
     </child>
   </widget>
   <packing>
     <property name="padding">0</property>
     <property name="expand">False</property>
     <property name="fill">False</property>
   </packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>

868
ScriptBasic Examples w/source / Password Entry Example
« on: March 26, 2006, 08:28:43 PM »
http://www.scriptbasic.org/cgi-bin/getpswd.bas

Code: [Select]

#!/usr/bin/scriba -c

INCLUDE cgi.bas

OPTION cgi$Method cgi::Post or cgi::Get

IF cgi::RequestMethod()="GET" THEN
  max_tries = 5
  tryno=1
  mypass = ""
END IF

IF cgi::RequestMethod()="POST" THEN
  IF cgi::PostParam("mypass")="LetMeIn" THEN
    cgi::Header 302,"text/html"
    PRINT "Location: /private.html\n"
    cgi::FinishHeader
    END
  END IF
  max_tries=cgi::PostParam("max_tries")
  tryno=cgi::PostParam("tryno")
  tryno = tryno + 1
  IF tryno > val(max_tries) THEN
    cgi::Header 302,"text/html"
    PRINT "Location: /home.html\n"
    cgi::FinishHeader
    END  
  END IF
END IF
cgi::Header 200,"text/html"
cgi::FinishHeader

PRINT """
<html>

Try number """ & tryno & """<br>

Enter Passsword:

<form method=post action=/cgi-bin/getpswd.bas>
  <input type=password name=mypass size=10>
  <input type=submit value="Go">
  <input type=hidden name=max_tries value=""" & max_tries & """>
  <input type=hidden name=tryno value=""" & tryno & """>
</form>
</html>
"""
END


--------------------------[home.html]------------------------------

<html>
<h1>Home Page</h1>
</html>

--------------------------[private.html]----------------------------

<html>
<h1>Private Page</h1>
</html>

869
ScriptBasic Examples w/source / CGI - ODBC Example
« on: March 26, 2006, 05:45:03 PM »
Code: Script BASIC
  1. #!/usr/bin/scriba -c
  2.  
  3. INCLUDE cgi.bas
  4. INCLUDE odbc.bas
  5.  
  6. cgi::Header 200,"text/html"
  7. cgi::FinishHeader
  8.  
  9. PRINT """
  10. <HTML>
  11. <HEAD>
  12. <title>unixODBC testing</title>
  13. </HEAD>
  14. <BODY>
  15. <FONT face="Verdana, Arial, Helvetica, sans-serif">
  16. <TABLE border="1" cellpadding="3">
  17. """
  18.  
  19. ON ERROR GOTO PROBLEMS
  20.  
  21. dbh = ODBC::RealConnect("DSN","user","password")
  22.  
  23. ODBC::query(dbh,"SELECT * FROM contact")
  24.  
  25. PRINT "File Handle: <b>",dbh,"</b><br>"
  26. PRINT "Affected Rows: <b>",ODBC::AffectedRows(dbh),"</b><br>"
  27.  
  28. WHILE ODBC::FetchHash(dbh,column)
  29.  
  30. PRINT "<TR>"
  31. PRINT "<TD>",column{"ID"},"</TD>"
  32. PRINT "<TD>",column{"NAME"},"</TD>"
  33. PRINT "<TD>",column{"ADDRESS"},"</TD>"
  34. PRINT "<TD>",column{"CITY"},"</TD>"
  35. PRINT "<TD>",column{"STATE"},"</TD>"
  36. PRINT "<TD>",column{"ZIP"},"</TD>"
  37. PRINT "<TD>",column{"PHONE"},"</TD>"
  38. PRINT "<TD>",column{"EMAIL"},"</TD>"
  39. PRINT "<TD>",column{"URL"},"</TD>"
  40. PRINT "</TR>"
  41.  
  42. WEND
  43.  
  44. PRINT """
  45. </TABLE>
  46. </FONT>
  47. </BODY>
  48. </HTML>
  49. """
  50.  
  51. ODBC::Close(dbh)
  52.  
  53. END
  54.  
  55. PROBLEMS:
  56.  
  57. PRINT "ERROR = ",error(),"<br>"
  58.  
  59. RESUME
  60.  

870
ScriptBasic Examples w/source / CGI - MySQL Example
« on: March 26, 2006, 05:42:01 PM »


Code: [Select]
#!/usr/bin/scriba -c

INCLUDE cgi.bas
INCLUDE mysql.bas

OPTION cgi$Method cgi::Post or cgi::Get

dbh = mysql::RealConnect("host","user","password","database")

mysql::query(dbh,"SELECT * FROM contact")

cgi::Header 200,"text/html"

cgi::FinishHeader

PRINT """
<HTML>
<HEAD>
<title>mySQL testing</title>
</HEAD>
<BODY>
"""
PRINT """<FONT face="Verdana, Arial, Helvetica, sans-serif">"""

PRINT """<TABLE border="1" cellpadding="3">"""

WHILE mysql::FetchHash(dbh,column)

PRINT "<TR>"
PRINT "<TD>",column{"ID"},"</TD>"
PRINT "<TD>",column{"NAME"},"</TD>"
PRINT "<TD>",column{"ADDRESS"},"</TD>"
PRINT "<TD>",column{"CITY"},"</TD>"
PRINT "<TD>",column{"STATE"},"</TD>"
PRINT "<TD>",column{"ZIP"},"</TD>"
PRINT "<TD>",column{"PHONE"},"</TD>"
PRINT "<TD>",column{"EMAIL"},"</TD>"
PRINT "<TD>",column{"URL"},"</TD>"
PRINT "</TR>"

WEND

PRINT "</TABLE>"

PRINT "<BR>"
PRINT "The database handle is: <b>",dbh,"</b><BR>"
PRINT "Affected rows by SELECT: <b>",mysql::AffectedRows(dbh),"</b><BR>"
PRINT "Character set name is: <b>",mysql::CharacterSetName(dbh),"</b><BR>"
PRINT "Last error is: <b>",mysql::ErrorMessage(dbh),"</b><BR>"
PRINT "Client info is: <b>",mysql::GetClientInfo(),"</b><BR>"
PRINT "Host info is: <b>",mysql::GetHostInfo(dbh),"</b><BR>"
PRINT "Proto info is: <b>",mysql::GetProtoInfo(dbh),"</b><BR>"
PRINT "Server info is: <b>",mysql::GetServerInfo(dbh),"</b><BR>"
PRINT "PING result: <b>",mysql::Ping(dbh),"</b><BR>"
PRINT "Thread ID: <b>",mysql::ThreadId(dbh),"</b><BR>"
PRINT "Status is: <b>",mysql::Stat(dbh),"</b><BR>"

PRINT "</FONT>"

PRINT """
</BODY>
</HTML>
"""

mysql::Close(dbh)

END

Pages: 1 ... 56 57 [58] 59