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 ... 36 37 [38] 39 40 ... 59
556
General Discussions / phpMyAdmin
« on: October 28, 2011, 09:23:08 PM »
phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute any SQL statement.


Project Web Site


557
Tutorials / RLIB - Report Writer
« on: October 28, 2011, 08:14:55 PM »
I have RLIB built under Ubuntu 64  and my preliminary testing using existing example code shows promise. I plan to show a scripted example of using this report writer.

Quote
RLIB is an advanced reporting engine that generates professional reports in PDF, HTML, CSV, and text formats from a simple XML definition language.










RLIB Project Site


558
Tutorials / SBGtk Calc
« on: October 26, 2011, 07:22:47 PM »
This is a scripted calculator example using a Glade GUI designer XML project file.



calc.sb
Code: [Select]
' Gtk Calculator

DECLARE SUB DLL ALIAS "_idll" LIB "gtk-server"
DECLARE SUB VARPTR ALIAS "varptr" LIB "gtk-server"
DECLARE SUB REQUIRE ALIAS "_idll_require" LIB "gtk-server"
DECLARE SUB DEFINE ALIAS "_idll_define" LIB "gtk-server"

DEFINE "gtk_init NONE NONE 2 NULL NULL"
DEFINE "glade_init NONE NONE 0"
DEFINE "glade_xml_new NONE WIDGET 3 STRING NULL NULL"
DEFINE "glade_xml_signal_autoconnect NONE NONE 1 WIDGET"
DEFINE "glade_xml_get_widget NONE WIDGET 2 WIDGET STRING"
DEFINE "gtk_entry_get_text NONE STRING 1 WIDGET"
DEFINE "gtk_entry_set_text NONE NONE 2 WIDGET STRING"
DEFINE "gtk_button_get_label NONE STRING 1 WIDGET"
DEFINE "gtk_server_connect NONE STRING 3 STRING STRING STRING"
DEFINE "gtk_server_callback NONE STRING 1 STRING"
DEFINE "gtk_server_exit NONE NONE 0"


' Initialize calculator state
calculator_state = 0

' Initialize calculator cache
calculator_cache = 0

' Initialize last calculator action
calculator_action = 0

' Initialize MEM function
mem = 0

' Process the action
SUB Handle_Operator(entry)
  LOCAL value
  IF calculator_state = 0 THEN
    IF calculator_action = 1 THEN
      value = DLL("gtk_entry_get_text " & entry)
      calculator_cache += value
      DLL("gtk_entry_set_text " & entry & " " & calculator_cache)
    ELSE IF calculator_action = 2 THEN
      value = DLL("gtk_entry_get_text " & entry)
      calculator_cache -= value
      DLL("gtk_entry_set_text " & entry & " " & calculator_cache)
    ELSE IF calculator_action = 3 THEN
      value = DLL("gtk_entry_get_text " & entry)
      calculator_cache *= value
      DLL("gtk_entry_set_text " & entry & " " & calculator_cache)
    ELSE IF calculator_action = 4 THEN
      value = DLL("gtk_entry_get_text " & entry)
      IF value = 0 THEN
        DLL("gtk_entry_set_text " & entry & " ERROR")
      ELSE
        calculator_cache /= value
        DLL("gtk_entry_set_text " & entry & " " & calculator_cache)
      END IF
    END IF
  END IF
END SUB

' All button actions here
SUB Button_Memread(entry, widget)
  calculator_state = 0
  calculator_cache = DLL("gtk_entry_get_text " & entry)
  DLL("gtk_entry_set_text " & entry & " " & mem)
END SUB

SUB Button_Memadd(entry, widget)
  mem = DLL("gtk_entry_get_text " & entry)
END SUB

SUB Button_C(entry, widget)
  DLL("gtk_entry_set_text " & entry & " 0")
END SUB

SUB Button_CE(entry, widget)
  calculator_state = 0
  calculator_action = 0
  calculator_cache = 0
  mem = 0
  DLL("gtk_entry_set_text " & entry & " 0")
END SUB

SUB Button_Add(entry, widget)
    Handle_Operator(entry)
    calculator_action = 1
    calculator_state += 1
END SUB

SUB Button_Subtract(entry, widget)
    Handle_Operator(entry)
    calculator_action = 2
    calculator_state += 1
END SUB

SUB Button_Multiply(entry, widget)
    Handle_Operator(entry)
    calculator_action = 3
    calculator_state += 1
END SUB

SUB Button_Divide(entry, widget)
    Handle_Operator(entry)
    calculator_action = 4
    calculator_state += 1
END SUB

SUB Button_Equals(entry, widget)
    Handle_Operator(entry)
    calculator_action = 0
    calculator_state += 1
END SUB

SUB Button_Clicked(entry, widget)
    LOCAL button, text
    button = DLL("gtk_button_get_label " & widget)
    text = DLL("gtk_entry_get_text " & entry)
    IF text = "0" OR calculator_state > 0 THEN
      calculator_cache = text
      DLL("gtk_entry_set_text " & entry & " " & button)
    ELSE
      DLL("gtk_entry_set_text " & entry & " " & text & button)
    END IF
    calculator_state = 0
END SUB

' Main program
DLL("gtk_init NULL NULL")
DLL("glade_init")
xml = DLL("glade_xml_new \"calc.glade\" NULL NULL")
DLL("glade_xml_signal_autoconnect " & xml)

' Calc_Exit
win = DLL("glade_xml_get_widget " &  xml & " window")
DLL("gtk_server_connect " & win & " delete-event window")

' Entry
ent = DLL("glade_xml_get_widget " & xml & " entry")

' Button_Clicked
but1 = DLL("glade_xml_get_widget " &  xml & " button1")
DLL("gtk_server_connect " & but1 & " clicked button1")
but2 = DLL("glade_xml_get_widget " &  xml & " button2")
DLL("gtk_server_connect " & but2 & " clicked button2")
but3 = DLL("glade_xml_get_widget " &  xml & " button3")
DLL("gtk_server_connect " & but3 & " clicked button3")
but4 = DLL("glade_xml_get_widget " &  xml & " button4")
DLL("gtk_server_connect " & but4 & " clicked button4")
but5 = DLL("glade_xml_get_widget " &  xml & " button5")
DLL("gtk_server_connect " & but5 & " clicked button5")
but6 = DLL("glade_xml_get_widget " &  xml & " button6")
DLL("gtk_server_connect " & but6 & " clicked button6")
but7 = DLL("glade_xml_get_widget " &  xml & " button7")
DLL("gtk_server_connect " & but7 & " clicked button7")
but8 = DLL("glade_xml_get_widget " &  xml & " button8")
DLL("gtk_server_connect " & but8 & " clicked button8")
but9 = DLL("glade_xml_get_widget " &  xml & " button9")
DLL("gtk_server_connect " & but9 & " clicked button9")
but0 = DLL("glade_xml_get_widget " &  xml & " button0")
DLL("gtk_server_connect " & but0 & " clicked button0")

' Button_Add
butADD = DLL("glade_xml_get_widget " &  xml & " buttonAdd")
DLL("gtk_server_connect " & butADD & " clicked buttonAdd")

' Button_Subtract
butSUB = DLL("glade_xml_get_widget " &  xml & " buttonMinus")
DLL("gtk_server_connect " & butSUB & " clicked buttonMinus")

' Button_Multiply
butMUL = DLL("glade_xml_get_widget " &  xml & " buttonMul")
DLL("gtk_server_connect " & butMUL & " clicked buttonMul")

' Button_Divide
butDIV = DLL("glade_xml_get_widget " &  xml & " buttonDiv")
DLL("gtk_server_connect " & butDIV & " clicked buttonDiv")

' Button_Equals
butEQ = DLL("glade_xml_get_widget " &  xml & " buttonEq")
DLL("gtk_server_connect " & butEQ & " clicked buttonEq")

' Button_C
butC = DLL("glade_xml_get_widget " &  xml & " buttonC")
DLL("gtk_server_connect " & butC & " clicked buttonC")

' Button_CE
butCE = DLL("glade_xml_get_widget " &  xml & " buttonCE")
DLL("gtk_server_connect " & butCE & " clicked buttonCE")

' Button_Memadd
memadd = DLL("glade_xml_get_widget " &  xml & " buttonMemadd")
DLL("gtk_server_connect " & memadd & " clicked buttonMemadd")

' Button_Memread
memread = DLL("glade_xml_get_widget " &  xml & " buttonMemread")
DLL("gtk_server_connect " & memread & " clicked buttonMemread")

REPEAT
  event = DLL("gtk_server_callback wait")
  IF event = "button1" THEN Button_Clicked(ent, but1)
  IF event = "button2" THEN Button_Clicked(ent, but2)
  IF event = "button3" THEN Button_Clicked(ent, but3)
  IF event = "button4" THEN Button_Clicked(ent, but4)
  IF event = "button5" THEN Button_Clicked(ent, but5)
  IF event = "button6" THEN Button_Clicked(ent, but6)
  IF event = "button7" THEN Button_Clicked(ent, but7)
  IF event = "button8" THEN Button_Clicked(ent, but8)
  IF event = "button9" THEN Button_Clicked(ent, but9)
  IF event = "button0" THEN Button_Clicked(ent, but0)
  IF event = "buttonAdd" THEN Button_Add(ent, butADD)
  IF event = "buttonMinus" THEN Button_Subtract(ent, butSUB)
  IF event = "buttonMul" THEN Button_Multiply(ent, butMUL)
  IF event = "buttonDiv" THEN Button_Divide(ent, butDIV)
  IF event = "buttonEq" THEN Button_Equals(ent, butEQ)
  IF event = "buttonC" THEN Button_C(ent, butC)
  IF event = "buttonCE" THEN Button_CE(ent, butCE)
  IF event = "buttonMemadd" THEN Button_Memadd(ent, memadd)
  IF event = "buttonMemread" THEN Button_Memread(ent, memread)
UNTIL event = "window"

DLL("gtk_server_exit")
END

calc.glade
Code: [Select]
<?xml version="1.0"?>
<glade-interface>
  <widget class="GtkWindow" id="window">
    <property name="width_request">250</property>
    <property name="height_request">225</property>
    <property name="visible">True</property>
    <property name="title" translatable="yes">SBGtk Calculator</property>
    <property name="resizable">False</property>
    <property name="window_position">center</property>
    <property name="default_width">264</property>
    <property name="default_height">248</property>
    <property name="icon_name">calc</property>
    <child>
      <widget class="GtkTable" id="table1">
        <property name="visible">True</property>
        <property name="n_rows">5</property>
        <property name="n_columns">5</property>
        <property name="homogeneous">True</property>
        <child>
          <widget class="GtkButton" id="buttonMemadd">
            <property name="label" translatable="yes">M+</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">3</property>
            <property name="right_attach">4</property>
            <property name="top_attach">4</property>
            <property name="bottom_attach">5</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkEntry" id="entry">
            <property name="visible">True</property>
            <property name="sensitive">False</property>
            <property name="editable">False</property>
            <property name="xalign">1</property>
          </widget>
          <packing>
            <property name="right_attach">5</property>
            <property name="x_padding">4</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button1">
            <property name="label" translatable="yes">1</property>
            <property name="width_request">0</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="top_attach">1</property>
            <property name="bottom_attach">2</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button3">
            <property name="label" translatable="yes">3</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">2</property>
            <property name="right_attach">3</property>
            <property name="top_attach">1</property>
            <property name="bottom_attach">2</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonC">
            <property name="label" translatable="yes">C</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">3</property>
            <property name="right_attach">4</property>
            <property name="top_attach">1</property>
            <property name="bottom_attach">2</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonCE">
            <property name="label" translatable="yes">CE</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">4</property>
            <property name="right_attach">5</property>
            <property name="top_attach">1</property>
            <property name="bottom_attach">2</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button4">
            <property name="label" translatable="yes">4</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="top_attach">2</property>
            <property name="bottom_attach">3</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button5">
            <property name="label" translatable="yes">5</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">1</property>
            <property name="right_attach">2</property>
            <property name="top_attach">2</property>
            <property name="bottom_attach">3</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button6">
            <property name="label" translatable="yes">6</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">2</property>
            <property name="right_attach">3</property>
            <property name="top_attach">2</property>
            <property name="bottom_attach">3</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonAdd">
            <property name="label" translatable="yes">+</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">3</property>
            <property name="right_attach">4</property>
            <property name="top_attach">2</property>
            <property name="bottom_attach">3</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonMinus">
            <property name="label" translatable="yes">-</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">4</property>
            <property name="right_attach">5</property>
            <property name="top_attach">2</property>
            <property name="bottom_attach">3</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button7">
            <property name="label" translatable="yes">7</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="top_attach">3</property>
            <property name="bottom_attach">4</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button8">
            <property name="label" translatable="yes">8</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">1</property>
            <property name="right_attach">2</property>
            <property name="top_attach">3</property>
            <property name="bottom_attach">4</property>
            <property name="x_padding">5</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button9">
            <property name="label" translatable="yes">9</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">2</property>
            <property name="right_attach">3</property>
            <property name="top_attach">3</property>
            <property name="bottom_attach">4</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonMul">
            <property name="label" translatable="yes">*</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">3</property>
            <property name="right_attach">4</property>
            <property name="top_attach">3</property>
            <property name="bottom_attach">4</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonDiv">
            <property name="label" translatable="yes">/</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">4</property>
            <property name="right_attach">5</property>
            <property name="top_attach">3</property>
            <property name="bottom_attach">4</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button0">
            <property name="label" translatable="yes">0</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="top_attach">4</property>
            <property name="bottom_attach">5</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonMemread">
            <property name="label" translatable="yes">MR</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">4</property>
            <property name="right_attach">5</property>
            <property name="top_attach">4</property>
            <property name="bottom_attach">5</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="buttonEq">
            <property name="label" translatable="yes">=</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">1</property>
            <property name="right_attach">3</property>
            <property name="top_attach">4</property>
            <property name="bottom_attach">5</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
        <child>
          <widget class="GtkButton" id="button2">
            <property name="label" translatable="yes">2</property>
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="receives_default">False</property>
          </widget>
          <packing>
            <property name="left_attach">1</property>
            <property name="right_attach">2</property>
            <property name="top_attach">1</property>
            <property name="bottom_attach">2</property>
            <property name="x_padding">4</property>
            <property name="y_padding">8</property>
          </packing>
        </child>
      </widget>
    </child>
  </widget>
</glade-interface>

559
Tutorials / FreeImage
« on: October 26, 2011, 09:29:28 AM »
Here is an example of scripting the FreeImage library under Linux. FreeImage is also available for Windows.

  • Get FreeImage version number
  • Get FreeImage copyright message
  • Load a jpg image
  • Get the image height and width
  • Rescale the jpg image from 225x225 to 100x100 using bicubic interpolation
  • Save the rescaled image as a png
  • Flip the original jpg image 180 degrees and save it as a png

Code: [Select]
DECLARE SUB DLL ALIAS "_idll" LIB "gtk-server"
DECLARE SUB VARPTR ALIAS "varptr" LIB "gtk-server"
DECLARE SUB REQUIRE ALIAS "_idll_require" LIB "gtk-server"
DECLARE SUB DEFINE ALIAS "_idll_define" LIB "gtk-server"

REQUIRE "libfreeimage.so"

DEFINE "FreeImage_GetVersion NONE STRING 0"
DEFINE "FreeImage_GetCopyrightMessage NONE STRING 0"
DEFINE "FreeImage_Load NONE LONG 3 INT STRING INT"
DEFINE "FreeImage_GetWidth NONE INT 1 LONG"
DEFINE "FreeImage_GetHeight NONE INT 1 LONG"
DEFINE "FreeImage_Rescale NONE LONG 4 LONG INT INT INT"
DEFINE "FreeImage_Save NONE BOOL 4 INT LONG STRING INT"
DEFINE "FreeImage_Rotate NONE LONG 3 LONG DOUBLE NULL"

CONST FIF_BMP  =  0
CONST FIF_JPEG =  2
CONST FIF_PNG  = 13
CONST FIF_GIF  = 25

CONST FILTER_BICUBIC = 1

PRINT DLL("FreeImage_GetVersion"),"\n"
PRINT DLL("FreeImage_GetCopyrightMessage"),"\n"
fbmp = DLL("FreeImage_Load " & FIF_JPEG & " \"world.jpg\" 0")
PRINT "Width: ",DLL("FreeImage_GetWidth " & fbmp),"\n"
PRINT "Height: ",DLL("FreeImage_GetHeight " & fbmp),"\n"
fbmps = DLL("FreeImage_Rescale " & fbmp & " 100 100 " & FILTER_BICUBIC)
DLL("FreeImage_Save " & FIF_PNG & " " & fbmps & " \"world_small.png\" 0")
fbmpr = DLL("FreeImage_Rotate " & fbmp & " 180 0")
DLL("FreeImage_Save " & FIF_PNG & " " & fbmpr & " \"world_flip.png\" 0")

Original .jpg image


Rescaled and converted to .png


Flipped 180 degrees


jrs@laptop:~/sb/FreeImage$ scriba fi.sb
3.13.1
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Width: 225
Height: 225
jrs@laptop:~/sb/FreeImage$


560
General Discussions / Re: cgi module
« on: October 21, 2011, 06:36:12 PM »
Ron,

I'm trying to understand what you're after. I assumed that you're sending  a request to a non-SB page/script that is looking for a special environmental variable to be set. Can you be more specific what you're trying to accomplish?

John

P.S.

Thanks for your feedback about SB.


561
General Discussions / Re: cgi module
« on: October 21, 2011, 06:45:58 AM »
Another way to set CGI environment variables is to specify them as either GET or as POST parameters in the http request.

562
General Discussions / Re: cgi module
« on: October 20, 2011, 09:39:23 PM »
After my previous post I gave the .htaccess method a try and it worked fine. That should be a quick way to solve your issue.

In general, how are your adventures going with ScriptBasic?


563
General Discussions / Re: cgi module
« on: October 20, 2011, 02:38:24 PM »
Ron,

I normally set environment variables with the SYSTEM or EXECUTE SB command. Are you starting your CGI scripts using the scriba -c command to tell SB that the script is CGI based?

Quote
CGI programs gain a great wealth of information from environment variables. This data is available to the ScriptBasic program via module functions. The CGI program is encouraged to use these functions instead of the function environ(). The reason to use these functions is that later versions of the CGI module may support ISAPI, NSAPI, FastCGI and other web server interface modes. Calling the function environ() to get the value of these variables will not work in that case, while calling the functions provided by the CGI module still works.

John

Update

Quote
.htaccess files are reread upon every hit within that directory. In fact, the web server will look for these .htaccess files on every access to the web server.

If using Apache, you may be able to set your environment variable by creating a .htaccess file in the directory your script is running and add the following.

SetEnv HTMLDOC_NOCGI "1"


564
HASH / Hash Fix
« on: October 12, 2011, 10:31:08 AM »
I was testing the HASH extension module on my Ubuntu 64 system and noticed it had the old out of memory error when calling the ThisValue() function. I have attached the interface.c that was fixed by AIR.

Code: [Select]
IMPORT hash.bas

h = hash::New()
hash::SetValue(h,"A1234567890",1)
hash::SetValue(h,"B12345678901234567890",2)
hash::SetValue(h,"C123456789012345678901234567890",3)
hash::Start(h)

FOR x = 1 to 3
  PRINT hash::ThisKey(h), " - "
  PRINT hash::ThisValue(h),"\n"
  hash::Next(h)
NEXT x

hash::Release(h)

jrs@laptop:~/sb/test$ scriba testhash.sb
A1234567890 - 1
B12345678901234567890 - 2
C123456789012345678901234567890 - 3
jrs@laptop:~/sb/test$

565
General Discussions / Re: SB2C
« on: October 03, 2011, 06:18:26 AM »
Thanks Ron for the heads up. Are you using the 32 or 64 bit version of ScriptBasic?

I'll post both here until I figure out why the .deb packages don't include it.

Update

I have attached the 32 and 64  bit versions of libscriba.so in a tar Z format.

566
Round Table / Re: Site Issues
« on: September 28, 2011, 09:19:03 PM »
The WIKI is back up with a current version of Mediawiki.

The Mambo 'home page' CMS is going to take a bit more work.


567
Round Table / Site Issues
« on: September 28, 2011, 07:18:42 PM »
ScriptBasic Site Visitor,

I had to upgrade the server to PHP 5.3.8 due to a Wordpress update requirement. This broke the ScriptBasic home page (Mambo) and the wiki. (Mediawiki)  I'm working on the problems and will post something here once it's working again.

Sorry for the inconvenience.


568
General Discussions / SB2C
« on: August 29, 2011, 01:31:07 AM »
If anyone is interested in creating small footprint compiled (C) applications with ScriptBasic, here is how it's done. (Linux, Win & Mac 32/64 bit)

Note: Paths used in this example may need adjustment based on where you installed ScriptBasic and the Linux platform you're running under.

Example SB script.
Code: [Select]
for x=-5 to 5
  print x,"\n"
next

Creating the C wrapper of the above script.

scriba -Co testfor.c testfor.bas

Code: [Select]
/* FILE: testfor.c
   This file contains the binary code of a ScriptBasic program
   To run this file you have to compile it to object file and
   link it with scribast.lib or whatever the library code is
   called on your platform.
*/
unsigned long ulGlobalVariables=1;
unsigned long ulNodeCounter=20;
unsigned long ulStartNode=7;
unsigned long ulStringTableSize=10;
unsigned char szCommandArray[] ={
0xB8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x76, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xCF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x4D, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00 };
char szStringTable[]={
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00,
0x00 };
#ifdef WIN32
main(int argc, char *argv[]){stndlone(argc,argv);}
#else
char **_environ;
main(int argc, char *argv[], char *env[]){stndlone(argc,argv,env);}
#endif
/*End of file testfor.c */

If you haven't created the sb.a runtime interface, here is how it's done.

cd /home/jrs/sb/scriptbasic/bin/obj/
ar rcs sb.a stndlone.o report.o myalloc.o errcodes.o dynlolib.o

chmod 755 sb.a
sudo cp sb.a /usr/lib

Make sure your ScriptBasic runtime shared object is present.

$ ls -l /usr/lib/libscriba*
-rwxr-xr-x 1 root root 1093954 2011-05-03 22:00 /usr/lib/libscriba.a
-rwxr-xr-x 1 root root  844476 2011-05-03 21:14 /usr/lib/libscriba.so

Looks like we are ready to compile our script.

$ gcc -Os testfor.c -I /home/jrs/sb/scriptbasic/ -ldl /usr/lib/sb.a -lscriba -lm -lpthread -o testfor

$ ./testfor
-5
-4
-3
-2
-1
0
1
2
3
4
5

$ ls -l testfor
-rwxr-xr-x 1 jrs jrs 29110 2011-08-29 00:17 testfor


This is an example of using the MySQL extension module and creating a standalone executable.

Code: [Select]
' MySQL Test Program

INCLUDE mysql.bas

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

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

WHILE mysql::FetchHash(dbh,column)

PRINTNL
PRINT column{"ID"},"\n"
PRINT column{"NAME"},"\n"
PRINTNL

WEND

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

mysql::Close(dbh)

END

$ scriba -Co tstsql.c testmysql.sb
$ gcc -Os tstsql.c -I /home/jrs/sb/scriptbasic/ -ldl /usr/lib/sb.a -lscriba -lm -lpthread -o tstsql
$ ./tstsql

1
John Spikowski


The database handle is: 1
Affected rows by SELECT: 1
Character set name is: latin1
Last error is:
Client info is: 5.1.54
Host info is: Localhost via UNIX socket
Proto info is: 10
Server info is: 5.1.54-1ubuntu4
PING result: -1
Thread ID: 0
Status is: Uptime: 28068  Threads: 1  Questions: 137  Slow queries: 0  Opens: 147  Flush tables: 1  Open tables: 35  Queries per second avg: 0.4

$ ls -l tstsql
-rwxr-xr-x 1 jrs jrs 35797 2011-08-29 02:54 tstsql

Compiling your scripts offers some distinct advantages over the scriba command line interpreter wrapper of the SBAPI.

  • Pre-compiled (tokenized) script
  • Shared object runtime
  • Static linking of extension modules rather than the default dynamic linking if desired

If you don't want to go through the trouble of converting the script to C and compiling with gcc, you can use the scriba command line option to create a standalone executable. This method attaches a tokenized (binay) version of the script to the end of a copy of scriba. Scriba always checks to see if there is a binary script attached before running the script name passed on the command line.

/usr/bin/scriba -Eo tstsql testmysql.sb



569
Round Table / Re: ssockets compile
« on: August 24, 2011, 12:24:53 AM »
That is one of Peter 's sites when he was a big fan of ScriptBasic. He went on to write his own Basic to C tranlator for Linux/Mac and left anything ScriptBasic related in AS IS status. His motivation for writing his own Basic was he wanted a 64 bit version of Basic running on TrueUnix/Linux but translated to C. He wrote his first version of the translator in the bash shell scripting language. If he would have assumed ScriptBasic would compile in a 64 bit environment, maybe BaCon would have never been written.I have been looking for an simple way to use scriba as a TCP server. Thanks for the reminder about Peter's ScriptBasic sockets contribution.

570
Round Table / Re: japi compile
« on: August 17, 2011, 06:46:34 PM »
Ron,

That's great news you were able to revive this extension to SB. I have attached the scriba examples and images from the JAPI site and put it in a zip for those wishing to join you on your adventure. Personally I have no interest in Java and the Windows 2000 looking GUI. (Latest Version: 26 Feb 2003 - V1.0.6)  This could be the reason it never got off the ground as an extension module for ScriptBasic. (project abandoned ?)

I'm happy with using GTK-Server and the GNOME Gtk API.

John

Pages: 1 ... 36 37 [38] 39 40 ... 59