A simple guestbook application. You'll need a SQLite database named guestbook.db with a table called guestbook. That guestbook database is made up of three columns:

  1. name varchar(100)
  2. message text
  3. id bigint

The following is the Run BASIC code.

[start]
cls
 
''' DISPLAY '''
' Starts the table
html "<table style=""width:100%;border:none;"">"
html "<tbody>"
html "<tr>"
html "<td style=""text-align:left;vertical-align:top;width:40%"">"
 
' The form
html "<p><b>Your Name:</b>"
textbox #yn, ""
html "</p>"
html "<p><b>Your Message:</b><br/>"
textarea #ym, ""
html "</p>"
link #add, "Add Message", [addnew]
print " ";
link #reset, "Reset", [start]
print ""
 
' Closes the first column
html "</td>"
html "<td style=""text-align:left;vertical-align:top;width:60%"">"
 
' Displays messages
html "<p>"
Call ListMessages
html "</p>"
 
' Closes the second column and table
html "</td></tr></tbody></table>"
wait
 
''' ADDS THE NEW MESSAGE '''
[addnew]
yn$ = #yn contents$()
ym$ = #ym contents$()
 
if yn$ = "" then yn$ = "Anonymous Coward" else yn$ = yn$
if ym$ = "" then ym$ = "Got nuthin to say." else ym$ = ym$
 
Call AddMsg yn$ ym$
goto [start]
 
''' FUNCTION AND SUB AREA '''
' Counts messages and gets a new, high, unique id number
function CountMsg$()
  sqliteconnect #msg, "guestbook.db"
  query$ = "select count(*) from guestbook"
  #msg execute(query$)
  result$ = #msg nextrow$("")
  lastcount = val(result$) + 1
  #msg disconnect()
  CountMsg$ = str$(lastcount)
end function
 
' Lists all messages
sub ListMessages
  sqliteconnect #msg, "guestbook.db"
  query$ = "select * from guestbook order by id desc"
  #msg execute(query$)
  while #msg hasanswer()
    result$ = #msg nextrow$("-|-")
    Call BuildMsg result$
  wend
  #msg disconnect()
end sub
 
' Inserts the new message into the database
sub AddMsg nam$ msg$
  lastcount$ = CountMsg$()
  sqliteconnect #msg, "guestbook.db"
  query$ = "insert into guestbook values ('" + nam$ + "', '" + msg$ + "', " + lastcount$ + ")"
  #msg execute(query$)
  #msg disconnect()
end sub
 
' Generates a single guestbook message
sub BuildMsg text$
  name$ = ""
  msg$ = ""
  id$ = ""
  commacnt = 0
  cnt = 1
 
  while cnt <= len(text$)
    temp$ = mid$(text$, cnt, 1)
 
    if mid$(text$, cnt, 3) = "-|-" then
      commacnt = commacnt + 1
      cnt = cnt + 3
    else
      select case commacnt
        case 0
          name$ = name$ + temp$
        case 1
          msg$ = msg$ + temp$
        case 2
          id$ = id$ + temp$
      end select
      cnt = cnt + 1
    end if
  wend
 
  html "<div id=""Message" + id$ + """>"
  html "<p><b>" + name$ + "</b><br/>" + msg$ + "</p>"
  html "</div>"
 
end sub