BASIC Developer & Support Resources > Scripting Languages

ScriptBasic Windows 32

<< < (3/4) > >>

John:


The cURL extension module provides support for various internet protocols.

libcurl home page

ScriptBasic libcurl documentation

cURL Include

--- Code: Script BASIC ---module curl declare sub ::Init       alias "sb_curl_init"     lib "curl"declare sub ::Option     alias "sb_curl_option"   lib "curl"declare sub ::Perform    alias "sb_curl_perform"  lib "curl"declare sub ::Finish     alias "sb_curl_finish"   lib "curl"declare sub ::Error      alias "sb_curl_error"    lib "curl"declare sub ::Info       alias "sb_curl_info"     lib "curl"declare sub ::Escape     alias "sb_curl_escape"   lib "curl"declare sub ::Unescape   alias "sb_curl_unescape" lib "curl"declare sub ::Getdate    alias "sb_curl_getdate"  lib "curl"declare sub ::Version    alias "sb_curl_version"  lib "curl" end module 

This example downloads the war-and-peace.txt file from the AllBASIC.info site.


--- Code: Script BASIC ---IMPORT curl.sbi ch = curl::init()PRINT "Downloading war-and-peace.txt ...\n"curl::option(ch, "URL", "https://allbasic.info/war-and-peace.txt")curl::option(ch, "FILE", "war-and-peace.txt")curl::option(ch,"NOPROGRESS",0)curl::perform(ch)PRINT curl::info(ch, "EFFECTIVE_URL"),"\n"PRINT FORMAT("Data downloaded: %0.0f bytes.\n", curl::info(ch, "SIZE_DOWNLOAD"))PRINT FORMAT("Total download time: %0.3f sec.\n", curl::info(ch, "TOTAL_TIME"))PRINT FORMAT("Average download speed: %0.3f kbyte/sec.\n", curl::info(ch, "SPEED_DOWNLOAD") / 1024)curl::finish(ch) 
Output

C:\ScriptBASIC\examples>sbc curl_wget.sb
Downloading war-and-peace.txt ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3214k  100 3214k    0     0  1672k      0  0:00:01  0:00:01 --:--:-- 1672k
https://allbasic.info/war-and-peace.txt
Data downloaded: 3291641 bytes.
Total download time: 1.922 sec.
Average download speed: 1672.473 kbyte/sec.

C:\ScriptBASIC\examples>


John:
The ScriptBasic COM extension module offers a CallByName COM/OLE automation interface. It is also tightly coupled with VB classic integration. The ScriptBasic IDE/Debugger is a good example of this integration.

COM Include

--- Code: Script BASIC ---GLOBAL CONST :GET    = 2GLOBAL CONST :LET    = 4GLOBAL CONST :CALL   = 1GLOBAL CONST :SET    = 8 MODULE COM DECLARE SUB ::CREATE  ALIAS "CreateObject"      LIB "com"DECLARE SUB ::CBN     ALIAS "CallByName"        LIB "com"DECLARE SUB ::RELEASE ALIAS "ReleaseObject"     LIB "com"DECLARE SUB ::GHO     ALIAS "GetHostObject"     LIB "com"DECLARE SUB ::GHS     ALIAS "GetHostString"     LIB "com"DECLARE SUB ::TN      ALIAS "TypeName"          LIB "com"DECLARE SUB ::DI      ALIAS "DescribeInterface" LIB "com" END MODULE 
This is an example of a VB6 OCX form I created to illustrate the concept. I converted the IUP online dictionary GUI form into an OCX, assigned methods and properties to it. When events occur the OCX form calls a ScriptBasic function / sub to process the event.


--- Code: Script BASIC ---IMPORT COM.sbiIMPORT NT.sbi servers[0]="dict.org"servers[1]="dict1.us.dict.org"servers[2]="all.dict.org" FUNCTION btnFetch_Clicked  LOCAL dat, total, count  ON ERROR GOTO G_NetError  server_selection = COM::CBN(obj, "CurrentServer")  OPEN server_selection & ":2628" FOR SOCKET AS #1  PRINT#1,"SHOW DB\n"  LINE INPUT#1, dat  LINE INPUT#1, dat  count = 0  WHILE LEFT(dat, 1) <> "."    LINE INPUT#1, dat    IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)    count+=1  WEND  PRINT#1,"QUIT\n"  CLOSE(#1)  FOR cnt = 0 TO count - 2    COM::CBN obj, "AddDictionaries", :CALL, total[cnt]  NEXT  COM::CBN obj, "DefaultDictionary"  btnFetch_Clicked = TRUE  EXIT FUNCTION   G_NetError:  NT::MsgBox "Server " & server_selection & " not available. (" & ERROR & ")", "OLD Error", "OK","Info", 1END FUNCTION FUNCTION btnSearch_clicked  LOCAL dict, dat, total, info  ON ERROR GOTO L_NetError  whichDictionary = COM::CBN(obj, "CurrentDictionary")  searchword = COM::CBN(obj, "SearchWord", :GET)  dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))  OPEN COM::CBN(obj, "CurrentServer") & ":2628" FOR SOCKET AS 1  IF COM::CBN(obj, "AllDict", :GET) THEN    PRINT#1,"DEFINE * " & searchword & "\n"  ELSE    PRINT#1,"DEFINE " & dict & " " & searchword & "\n"  END IF  REPEAT    LINE INPUT#1, dat    IF LEFT(dat, 3) = "151" THEN      total$ &= "------------------------------\r\n"      total$ &= RIGHT(dat, LEN(dat) - LEN(searchword) - LEN(dict))      total$ &= "------------------------------\r\n"      REPEAT        LINE INPUT#1, info        info = REPLACE(info, CHR(34), CHR(92) & CHR(34))        IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\r\n"      UNTIL LEFT(info, 1) = "."      total &= "\r\n"    END IF  UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499  PRINT#1,"QUIT\n"  CLOSE(#1)  IF LEFT(dat, 3) = "552" THEN    total = "No match found."  ELSE IF LEFT(dat, 3) = "501" THEN    total = "Select a dictionary first!"  ELSE IF LEFT(dat, 3) = "550" THEN    total = "Invalid database!"  END IF  COM::CBN(obj, "SetTranslation", :CALL, total)  btnSearch_Clicked = TRUEEXIT FUNCTION L_NetError:  dat[0] = "Could not lookup word! (" & ERROR & ")"  COM::CBN(obj, "SetTranslation", :CALL, dat)END FUNCTION ' MAIN obj = COM::CREATE(:SET, "OLD.OLDict")oCollection = COM::CBN(obj, "CallBackHandlers", :GET)COM::CBN oCollection, "Add", :CALL, ADDRESS(btnFetch_Clicked()), "win.btnFetch_Click"COM::CBN oCollection, "Add", :CALL, ADDRESS(btnSearch_Clicked()), "win.btnSearch_Click"FOR idx = 0 TO UBOUND(servers)  COM::CBN obj, "AddServer", :CALL, servers[idx]NEXT  COM::CBN obj, "DefaultServer"COM::CBN obj, "ShowOLD"COM::RELEASE obj 



John:


The SDL_gfx extension module provides the following features.

The SDL_gfx library evolved out of the SDL_gfxPrimitives code which provided basic drawing routines such as lines, circles or polygons for SDL Surfaces and adding a couple other useful functions for zooming images for example and doing basic image processing on byte arrays.

Note that SDL_gfx is compatible with SDL version 1.2 (not SDL2).

The current components of the SDL_gfx library are:
[*] Graphic Primitives
[*] Rotozoomer
[*] Framerate control
[*] MMX image filters
[*] Custom Blit functions
[*] Build-in 8x8 Font
[/list]

ScriptBasic GFX Include

--- Code: Script BASIC ---MODULE GFX DECLARE SUB    ::Window                    ALIAS     "gfx_Window"                    LIB  "gfx"DECLARE SUB    ::Close                     ALIAS     "gfx_Close"                     LIB  "gfx"DECLARE SUB    ::Update                    ALIAS     "gfx_Update"                    LIB  "gfx"DECLARE SUB    ::ClearScreen               ALIAS     "gfx_ClearScreen"               LIB  "gfx"DECLARE SUB    ::SDL_SetClipRect           ALIAS     "gfx_SDL_SetClipRect"           LIB  "gfx"DECLARE SUB    ::Time                      ALIAS     "gfx_Time"                      LIB  "gfx"DECLARE SUB    ::Shift                     ALIAS     "gfx_Shift"                     LIB  "gfx"DECLARE SUB    ::Rotate                    ALIAS     "gfx_Rotate"                    LIB  "gfx"DECLARE SUB    ::GetKey                    ALIAS     "gfx_GetKey"                    LIB  "gfx"DECLARE SUB    ::WaitKey                   ALIAS     "gfx_WaitKey"                   LIB  "gfx"DECLARE SUB    ::KeyName                   ALIAS     "gfx_KeyName"                   LIB  "gfx"DECLARE SUB    ::Mouse                     ALIAS     "gfx_Mouse"                     LIB  "gfx"DECLARE SUB    ::pixelColor                ALIAS     "gfx_pixelColor"                LIB  "gfx"DECLARE SUB    ::pixelRGBA                 ALIAS     "gfx_pixelRGBA"                 LIB  "gfx"DECLARE SUB    ::hlineColor                ALIAS     "gfx_hlineColor"                LIB  "gfx"DECLARE SUB    ::hlineRGBA                 ALIAS     "gfx_hlineRGBA"                 LIB  "gfx"DECLARE SUB    ::vlineColor                ALIAS     "gfx_vlineColor"                LIB  "gfx"DECLARE SUB    ::vlineRGBA                 ALIAS     "gfx_vlineRGBA"                 LIB  "gfx"DECLARE SUB    ::rectangleColor            ALIAS     "gfx_rectangleColor"            LIB  "gfx"DECLARE SUB    ::rectangleRGBA             ALIAS     "gfx_rectangleRGBA"             LIB  "gfx"DECLARE SUB    ::roundedRectangleColor     ALIAS     "gfx_roundedRectangleColor"     LIB  "gfx"DECLARE SUB    ::roundedRectangleRGBA      ALIAS     "gfx_roundedRectangleRGBA"      LIB  "gfx"DECLARE SUB    ::boxColor                  ALIAS     "gfx_boxColor"                  LIB  "gfx"DECLARE SUB    ::boxRGBA                   ALIAS     "gfx_boxRGBA"                   LIB  "gfx"DECLARE SUB    ::roundedBoxColor           ALIAS     "gfx_roundedBoxColor"           LIB  "gfx"DECLARE SUB    ::roundedBoxRGBA            ALIAS     "gfx_roundedBoxRGBA"            LIB  "gfx"DECLARE SUB    ::lineColor                 ALIAS     "gfx_lineColor"                 LIB  "gfx"DECLARE SUB    ::lineRGBA                  ALIAS     "gfx_lineRGBA"                  LIB  "gfx"DECLARE SUB    ::aalineColor               ALIAS     "gfx_aalineColor"               LIB  "gfx"DECLARE SUB    ::aalineRGBA                ALIAS     "gfx_aalineRGBA"                LIB  "gfx"DECLARE SUB    ::thickLineColor            ALIAS     "gfx_thickLineColor"            LIB  "gfx"DECLARE SUB    ::thickLineRGBA             ALIAS     "gfx_thickLineRGBA"             LIB  "gfx"DECLARE SUB    ::circleColor               ALIAS     "gfx_circleColor"               LIB  "gfx"DECLARE SUB    ::circleRGBA                ALIAS     "gfx_circleRGBA"                LIB  "gfx"DECLARE SUB    ::arcColor                  ALIAS     "gfx_arcColor"                  LIB  "gfx"DECLARE SUB    ::arcRGBA                   ALIAS     "gfx_arcRGBA"                   LIB  "gfx"DECLARE SUB    ::aacircleColor             ALIAS     "gfx_aacircleColor"             LIB  "gfx"DECLARE SUB    ::aacircleRGBA              ALIAS     "gfx_aacircleRGBA"              LIB  "gfx"DECLARE SUB    ::filledCircleColor         ALIAS     "gfx_filledCircleColor"         LIB  "gfx"DECLARE SUB    ::filledCircleRGBA          ALIAS     "gfx_filledCircleRGBA"          LIB  "gfx"DECLARE SUB    ::ellipseColor              ALIAS     "gfx_ellipseColor"              LIB  "gfx"DECLARE SUB    ::ellipseRGBA               ALIAS     "gfx_ellipseRGBA"               LIB  "gfx"DECLARE SUB    ::aaellipseColor            ALIAS     "gfx_aaellipseColor"            LIB  "gfx"DECLARE SUB    ::aaellipseRGBA             ALIAS     "gfx_aaellipseRGBA"             LIB  "gfx"DECLARE SUB    ::filledEllipseColor        ALIAS     "gfx_filledEllipseColor"        LIB  "gfx"DECLARE SUB    ::filledEllipseRGBA         ALIAS     "gfx_filledEllipseRGBA"         LIB  "gfx"DECLARE SUB    ::pieColor                  ALIAS     "gfx_pieColor"                  LIB  "gfx"DECLARE SUB    ::pieRGBA                   ALIAS     "gfx_pieRGBA"                   LIB  "gfx"DECLARE SUB    ::filledPieColor            ALIAS     "gfx_filledPieColor"            LIB  "gfx"DECLARE SUB    ::filledPieRGBA             ALIAS     "gfx_filledPieRGBA"             LIB  "gfx"DECLARE SUB    ::trigonColor               ALIAS     "gfx_trigonColor"               LIB  "gfx"DECLARE SUB    ::trigonRGBA                ALIAS     "gfx_trigonRGBA"                LIB  "gfx"DECLARE SUB    ::aatrigonColor             ALIAS     "gfx_aatrigonColor"             LIB  "gfx"DECLARE SUB    ::aatrigonRGBA              ALIAS     "gfx_aatrigonRGBA"              LIB  "gfx"DECLARE SUB    ::filledTrigonColor         ALIAS     "gfx_filledTrigonColor"         LIB  "gfx"DECLARE SUB    ::filledTrigonRGBA          ALIAS     "gfx_filledTrigonRGBA"          LIB  "gfx"DECLARE SUB    ::polygonColor              ALIAS     "gfx_polygonColor"              LIB  "gfx"DECLARE SUB    ::polygonRGBA               ALIAS     "gfx_polygonRGBA"               LIB  "gfx"DECLARE SUB    ::aapolygonColor            ALIAS     "gfx_aapolygonColor"            LIB  "gfx"DECLARE SUB    ::aapolygonRGBA             ALIAS     "gfx_aapolygonRGBA"             LIB  "gfx"DECLARE SUB    ::filledPolygonColor        ALIAS     "gfx_filledPolygonColor"        LIB  "gfx"DECLARE SUB    ::filledPolygonRGBA         ALIAS     "gfx_filledPolygonRGBA"         LIB  "gfx"DECLARE SUB    ::texturedPolygon           ALIAS     "gfx_texturedPolygon"           LIB  "gfx"DECLARE SUB    ::bezierColor               ALIAS     "gfx_bezierColor"               LIB  "gfx"DECLARE SUB    ::bezierRGBA                ALIAS     "gfx_bezierRGBA"                LIB  "gfx"DECLARE SUB    ::SetFont                   ALIAS     "gfx_SetFont"                   LIB  "gfx"DECLARE SUB    ::FontRotation              ALIAS     "gfx_FontRotation"              LIB  "gfx"DECLARE SUB    ::characterColor            ALIAS     "gfx_characterColor"            LIB  "gfx"DECLARE SUB    ::characterRGBA             ALIAS     "gfx_characterRGBA"             LIB  "gfx"DECLARE SUB    ::stringColor               ALIAS     "gfx_stringColor"               LIB  "gfx"DECLARE SUB    ::stringRGBA                ALIAS     "gfx_stringRGBA"                LIB  "gfx"DECLARE SUB    ::SDL_initFramerate         ALIAS     "gfx_SDL_initFramerate"         LIB  "gfx"DECLARE SUB    ::SDL_getFramerate          ALIAS     "gfx_SDL_getFramerate"          LIB  "gfx"DECLARE SUB    ::SDL_setFramerate          ALIAS     "gfx_SDL_setFramerate"          LIB  "gfx"DECLARE SUB    ::SDL_framerateDelay        ALIAS     "gfx_SDL_framerateDelay"        LIB  "gfx"DECLARE SUB    ::CreateSurface             ALIAS     "gfx_CreateSurface"             LIB  "gfx"DECLARE SUB    ::FreeSurface               ALIAS     "gfx_FreeSurface"               LIB  "gfx"DECLARE SUB    ::BlitSurface               ALIAS     "gfx_BlitSurface"               LIB  "gfx"DECLARE SUB    ::LoadBMP                   ALIAS     "gfx_LoadBMP"                   LIB  "gfx"DECLARE SUB    ::GetPixel                  ALIAS     "gfx_GetPixel"                  LIB  "gfx"DECLARE SUB    ::GetPixelRGBA              ALIAS     "gfx_GetPixelRGBA"              LIB  "gfx"DECLARE SUB    ::Mandelbrot                ALIAS     "gfx_Mandelbrot"                LIB  "gfx" END MODULE 
SDL_gfx Demo - Basic Primitives




--- Code: Script BASIC ---' SDL_gfx Demo IMPORT gfx.sbi win = gfx::Window(700, 600, "ScriptBasic SDL_gfx Demo")gfx::pixelRGBA(win, 10, 15, 255, 255, 255, 255)gfx::lineRGBA(win, 20, 10, 70, 90, 255, 0, 0, 255)gfx::trigonRGBA(win, 500, 50, 550, 200, 600, 150, 0, 255, 255, 255)gfx::filledTrigonRGBA(win, 200, 200, 300, 50, 400, 200, 0, 0, 255, 255)gfx::rectangleRGBA(win, 10, 300, 100, 380, 0, 255, 0, 255)gfx::boxRGBA(win, 210, 76, 325, 300, 255, 0, 0, 150)gfx::ellipseRGBA(win, 600, 400, 50, 90, 255, 255, 0, 200)gfx::filledEllipseRGBA(win, 600, 400, 25, 150, 0, 255, 0, 255)SPLIT "350,275,300,325,350,400,325,325,390,390,375" BY "," TO _      x[0],x[1],x[2],x[3],x[4],x[5],y[0],y[1],y[2],y[3],y[4]gfx::polygonRGBA(win, x, y, 6, 255, 255, 255, 155)SPLIT "400,450,450,425,300,400,410,450,425,500" BY "," TO _      s[0],s[1],s[2],s[3],s[4],t[0],t[1],t[2],t[3],t[4]gfx::filledPolygonRGBA(win, s, t, 5, 255, 0, 255, 155)gfx::stringColor win, 250, 550, "Press ESC key to QUIT" & CHR(0), 0xffffffffgfx::UpdateWHILE gfx::KeyName(1) <> "+escape"WENDgfx::Close 
Alpha Circles




--- Code: Script BASIC ---' ScriptBasic GFX - Alpha Circles IMPORT gfx.sbi scrn = gfx::Window(640, 480, "ScriptBasic GFX - Alpha Circles")' Random Value ArraysRANDOMIZE(gfx::Time())FOR i = 0 TO 512  rx[i] = RND() % 640  ry[i] = 60 + RND() % 480 - 80  rz[i] = RND() % 64  rr[i] = RND() AND  255  rg[i] = RND() AND  255  rb[i] = RND() AND  255  af = rx[i] / 640  ra[i] = INT(255 * af)NEXT ts = gfx::Time()FOR i = 0 TO 512  gfx::filledCircleRGBA scrn, rx[i], ry[i], rz[i], rr[i], rg[i], rb[i], ra[i]NEXTte = gfx::Time()gfx::stringColor scrn, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0xffffffffgfx::UpdateWHILE gfx::KeyName(1) <> "+escape"WENDgfx::Close 
Mandelbrot Fractal




--- Code: Script BASIC ---' ScriptBasic GFX - Mandelbrot IMPORT gfx.sbi s = gfx::Window(640,480,"ScriptBasic SDL_gfx Mandelbrot")ts = gfx::Time()FOR y = 0 TO 479  FOR x = 0 TO 639    cx = (x - 320) / 120    cy = (y - 240) / 120    rit = gfx::Mandelbrot(cx, cy, 510)    gfx::PixelRGBA s, x, y, rit * 32, rit * 16, rit * 8, 255  NEXTNEXTte = gfx::Time()gfx::stringColor s, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0x000000ffgfx::UpdateWHILE gfx::KeyName(1) <> "+escape"WENDgfx::Close 

John:


The SQLite extension module provides core SQL CRUD functions in a lightweight DB library.

SQLite Home Page


SQLite Include

--- Code: Script BASIC ---module sqlite SQLITE3_OK          =   0SQLITE3_ERROR       =   1SQLITE3_INTERNAL    =   2SQLITE3_PERM        =   3SQLITE3_ABORT       =   4 SQLITE3_BUSY        =   5SQLITE3_LOCKED      =   6SQLITE3_NOMEM       =   7SQLITE3_READONLY    =   8SQLITE3_INTERRUPT   =   9 SQLITE3_IOERR       =  10 SQLITE3_CORRUPT     =  11 SQLITE3_NOTFOUND    =  12  SQLITE3_FULL        =  13 SQLITE3_CANTOPEN    =  14  SQLITE3_PROTOCOL    =  15  SQLITE3_EMPTY       =  16  SQLITE3_SCHEMA      =  17 SQLITE3_TOOBIG      =  18 SQLITE3_CONStraint  =  19 SQLITE3_MISMATCH    =  20 SQLITE3_MISUSE      =  21 SQLITE3_NOLFS       =  22 SQLITE3_AUTH        =  23 SQLITE3_ROW         = 100 SQLITE3_DONE        = 101 SQLITE3_STATIC      =   0SQLITE_TRANSIENT    =  -1 SQLITE_INTEGER      =   1SQLITE_FLOAT        =   2SQLITE_TEXT         =   3SQLITE_BLOB         =   4SQLITE_NULL         =   5      ' FUNCTION DECLARATIONS declare sub     ::OPEN         alias "sql3_open"         lib "sqlite"declare sub     ::CLOSE        alias "sql3_close"        lib "sqlite"declare sub     ::EXECUTE      alias "sql3_execute"      lib "sqlite"declare sub     ::QUERY        alias "sql3_query"        lib "sqlite"declare sub     ::ROW          alias "sql3_row"          lib "sqlite"declare sub     ::ROW_VALUE    alias "sql3_row_value"    lib "sqlite"declare sub     ::COLUMN_COUNT alias "sql3_column_count" lib "sqlite"declare sub     ::COLUMN_NAME  alias "sql3_column_name"  lib "sqlite"declare sub     ::FINALIZE     alias "sql3_finalize"     lib "sqlite"declare sub     ::VERSION      alias "sql3_version"      lib "sqlite"declare sub     ::ErrorCode    alias "sql3_errorcode"    lib "sqlite"declare sub     ::ErrorMsg     alias "sql3_errormsg"     lib "sqlite"declare sub     ::FETCHHASH    alias "sql3_fetchhash"    lib "sqlite"declare sub     ::FETCHARRAY   alias "sql3_fetcharray"   lib "sqlite" end module 
SQLite Demo

--- Code: Script BASIC ---' SQLite CREATE / INSERT / SELECT IMPORT sqlite.sbi db = sqlite::open("sqlite_demo.db") sqlite::execute(db,"create table demo (someval integer, sometxt text);")sqlite::execute(db,"insert into demo values (123,'hello');")sqlite::execute(db, "INSERT INTO demo VALUES (234, 'cruel');")sqlite::execute(db, "INSERT INTO demo VALUES (345, 'world');")  stmt = sqlite::query(db,"SELECT * FROM demo") WHILE sqlite::row(stmt) = sqlite::SQLITE3_ROW  IF sqlite::fetchhash(stmt, column) THEN    PRINT column{"someval"},"\t-\t",column{"sometxt"},"\n"  END IFWEND sqlite::close(db) 
Output

C:\ScriptBASIC\examples>sbc sqlite_demo.sb
123     -       hello
234     -       cruel
345     -       world

C:\ScriptBASIC\examples>


John:


The MySQL extension module is a C client interface to the MySQL Server Database.

MySQL Include

--- Code: Script BASIC ---module mysql declare sub ::RealConnect alias "mys_real_connect" lib "mysql"declare sub ::Connect alias "mys_config_connect" lib "mysql"declare sub ::Close alias "mys_close" lib "mysql"declare sub ::Query alias "mys_query" lib "mysql"declare sub ::FetchArray alias "mys_fetcharray" lib "mysql"declare sub ::FetchHash alias "mys_fetchhash" lib "mysql"declare sub ::AffectedRows alias "mys_affected_rows" lib "mysql"declare sub ::ChangeUser alias "mys_change_user" lib "mysql"declare sub ::CharacterSetName alias "mys_character_set_name" lib "mysql"declare sub ::DataSeek alias "mys_data_seek" lib "mysql"declare sub ::ErrorMessage alias "mys_error" lib "mysql"declare sub ::GetClientInfo alias "mys_get_client_info" lib "mysql"declare sub ::GetHostInfo alias "mys_get_host_info" lib "mysql"declare sub ::GetProtoInfo alias "mys_get_proto_info" lib "mysql"declare sub ::GetServerInfo alias "mys_get_server_info" lib "mysql"declare sub ::Info alias "mys_info" lib "mysql"declare sub ::InsertId alias "mys_insert_id" lib "mysql"declare sub ::Kill alias "mys_kill" lib "mysql"declare sub ::Ping alias "mys_ping" lib "mysql"declare sub ::EscapeString alias "mys_real_escape_string" lib "mysql"declare sub ::SelectDatabase alias "mys_select_db" lib "mysql"declare sub ::Shutdown alias "mys_shutdown" lib "mysql"declare sub ::Stat alias "mys_stat" lib "mysql"declare sub ::ThreadId alias "mys_thread_id" lib "mysql" end module 
This MySQL demo shows getting cars from a model DB.

--- Code: SQL ---CREATE TABLE IF NOT EXISTS `products` (  `productCode` VARCHAR(15) NOT NULL,  `productName` VARCHAR(70) NOT NULL,  `productLine` VARCHAR(50) NOT NULL,  `productScale` VARCHAR(10) NOT NULL,  `productVendor` VARCHAR(50) NOT NULL,  `productDescription` text NOT NULL,  `quantityInStock` SMALLINT(6) NOT NULL,  `buyPrice` DOUBLE NOT NULL,  `MSRP` DOUBLE NOT NULL,  PRIMARY KEY (`productCode`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; 
mysql_demo.sb

--- Code: Script BASIC ---' MySQL Demo Program INCLUDE mysql.sbi dbh = mysql::RealConnect("localhost","user","password","classicmodels")PRINT "Got Here\n"mysql::query(dbh,"SELECT * FROM products WHERE productLine = 'Classic Cars'") WHILE mysql::FetchHash(dbh,column)  PRINT column{"productCode"}," - ",column{"productName"}," - ",FORMAT("%~$###.00~",column{"MSRP"}),"\n"WEND PRINTNLPRINT "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) 
Output

C:\ScriptBASIC\examples>sbc mysql_demo.sb
S10_1949 - 1952 Alpine Renault 1300 - $214.30
S10_4757 - 1972 Alfa Romeo GTA - $136.00
S10_4962 - 1962 LanciaA Delta 16V - $147.74
S12_1099 - 1968 Ford Mustang - $194.57
S12_1108 - 2001 Ferrari Enzo - $207.80
S12_3148 - 1969 Corvair Monza - $151.08
S12_3380 - 1968 Dodge Charger - $117.44
S12_3891 - 1969 Ford Falcon - $173.02
S12_3990 - 1970 Plymouth Hemi Cuda - $ 79.80
S12_4675 - 1969 Dodge Charger - $115.16
S18_1129 - 1993 Mazda RX-7 - $141.54
S18_1589 - 1965 Aston Martin DB5 - $124.44
S18_1889 - 1948 Porsche 356-A Roadster - $ 77.00
S18_1984 - 1995 Honda Civic - $142.25
S18_2238 - 1998 Chrysler Plymouth Prowler - $163.73
S18_2870 - 1999 Indy 500 Monte Carlo SS - $132.00
S18_3232 - 1992 Ferrari 360 Spider red - $169.34
S18_3233 - 1985 Toyota Supra - $107.57
S18_3278 - 1969 Dodge Super Bee - $ 80.41
S18_3482 - 1976 Ford Gran Torino - $146.99
S18_3685 - 1948 Porsche Type 356 Roadster - $141.28
S18_4027 - 1970 Triumph Spitfire - $143.62
S18_4721 - 1957 Corvette Convertible - $148.80
S18_4933 - 1957 Ford Thunderbird - $ 71.27
S24_1046 - 1970 Chevy Chevelle SS 454 - $ 73.49
S24_1444 - 1970 Dodge Coronet - $ 57.80
S24_1628 - 1966 Shelby Cobra 427 S/C - $ 50.31
S24_2766 - 1949 Jaguar XK 120 - $ 90.87
S24_2840 - 1958 Chevy Corvette Limited Edition - $ 35.36
S24_2887 - 1952 Citroen-15CV - $117.44
S24_2972 - 1982 Lamborghini Diablo - $ 37.76
S24_3191 - 1969 Chevrolet Camaro Z28 - $ 85.61
S24_3371 - 1971 Alpine Renault 1600s - $ 61.23
S24_3432 - 2002 Chevy Corvette - $107.08
S24_3856 - 1956 Porsche 356A Coupe - $140.43
S24_4048 - 1992 Porsche Cayenne Turbo Silver - $118.28
S24_4620 - 1961 Chevrolet Impala - $ 80.84
S700_2824 - 1982 Camaro Z28 - $101.15

The database handle is: 1
Affected rows by SELECT: 38
Character set name is: latin1
Last error is:
Client info is: 6.0.0
Host info is: localhost via TCP/IP
Proto info is: 10
Server info is: 8.0.20
PING result: -1
Thread ID: 0
Status is: Uptime: 7690  Threads: 6  Questions: 10766  Slow queries: 0  Opens: 726  Flush tables: 3  Open tables: 633  Queries per second avg: 1.400

C:\ScriptBASIC\examples>


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version