1 (edited by ScriptBASIC 11/01/2015 12:07:06 am)

Topic: Script BASIC

Hi FA Forum Members,

I manage the Script BASIC open source project and support the language on the commercial front. I think FA is an outstanding foundation ERP that can go in just about any direction. I'm looking forward to work with it.

I just wanted to say hi and will be following the forum closely.

John Spikowski
support@scriptbasic.org
www.scriptbasic.org

2 (edited by apmuthu 11/01/2015 01:01:07 pm)

Re: Script BASIC

@John Spikowski: Found your project interesting - recalled fond '80s memories of the ZX81 BASIC on the TV and tape recorder!

In what way do you envisage your project being used with FrontAccounting?
Perhaps it has a way of interacting with MySQL databases natively in both Linux and Windows (ODBC?).
Can it do some CRONs for FA like folder monitoring and emailing or bridging between POS / CRM applications and FA?
Can it's intermediate compiled code be decompiled back?

Re: Script BASIC

Found your project interesting - recalled fond '80s memories of the ZX81 BASIC on the TV and tape recorder!

It's an embeddable scripting language written in ANSI C and runs on everything. It's thread safe with unlimited expansion through it C extension API. You should have a second look. ;-)

Re: Script BASIC

Whilst FA is interpreted, executed and presented to the Web Browser (not necessarily on CGI), how would we get to use ScriptBASIC with it? Please provide an example of it's usage with PHP (non CGI).

Re: Script BASIC

I have an echo example of the Script BASIC multi-thread HTTP application proxy server running on my www.Koding.com account if you would like to take a peak. (750 KB total) php core starts at 3 MB per session. A painted elephant. yikes

Script BASIC web server - echo (scales like nothing else out there)

It supports MySQL, (unix)ODBC, SQLite, Curl, ... as extension modules that seamlessly extend the language.

I'll post a few more examples if there is interest.

Re: Script BASIC

Here is a cool project a Script BASIC sbhttpd user did. It uses the GD extension module to create live buoy weather data graphics overlayed on satellite  images. They use the Script BASIC sbhttpd server for the task.

Worldwide Buoy Weather

Re: Script BASIC

Please post some php source interacting with ScriptBASIC source code.

Re: Script BASIC

apmuthu wrote:

Please post some php source interacting with ScriptBASIC source code.

The Script BASIC sbhttpd proxy server is a replacement for PHP. The syntax is traditional BASIC with a sprinkle of Perl and Python syntax mixed in.

Here is the code to the echo example I posted previously.

global const nl = "\n"
Const NumberOfCookies = 3

include cgi.bas

option cgi$Method cgi::Get or cgi::Upload

' cgi::RequestBasicAuthentication "Test Realm"
cgi::Header 200,"text/html"

'
' We are setting several cookies. The expiry time is ten seconds so you can test that
' the cookies are sent by the browser if you press some of the buttons fast enough,
' but it does not if you are slow
'
for i=1 to NumberOfCookies 
  ' cookie(i) is i, no domain is defined, path is /, expires after 5 seconds, not secure
  cgi::SetCookie "cookie" & i,i,undef,"/",gmtime()+10,false
next i

cgi::FinishHeader

'-------------------------------------------------------
print """<HTML>
<HEAD>
<title>CGI parameter testing</title>
</HEAD>
<BODY><font face="VERDANA" size="2">
<H1>View CGI Parameters</H1>
This page shows the cgi parameters the way it was uploaded.
<!-- here is the result of the previous HTTP request -->
<FONT SIZE="3">
<PRE>
CGI system variables
--------------------

"""
'-------------------------------------------------------

print "ServerSoftware  = ",cgi::ServerSoftware(), nl
print "ServerName      = ",cgi::ServerName(), nl
print "GatewayInterface= ",cgi::GatewayInterface(),nl
print "ServerProtocol  = ",cgi::ServerProtocol(), nl
print "ServerPort      = ",cgi::ServerPort(), nl
print "RequestMethod   = ",cgi::RequestMethod(), nl
print "PathInfo        = ",cgi::PathInfo(), nl
print "PathTranslated  = ",cgi::PathTranslated(), nl
print "ScriptName      = ",cgi::ScriptName(), nl
print "QueryString     = ",cgi::QueryString(), nl
print "RemoteHost      = ",cgi::RemoteHost(), nl
print "RemoteAddress   = ",cgi::RemoteAddress(), nl
print "AuthType        = ",cgi::AuthType(), nl
print "RemoteUser      = ",cgi::RemoteUser(), nl
print "RemoteIdent     = ",cgi::RemoteIdent(), nl
print "ContentType     = ",cgi::ContentType(), nl
print "ContentLength   = ",cgi::ContentLength(), nl
print "UserAgent       = ",cgi::UserAgent(), nl
print "Cookie          = ",cgi::RawCookie(), nl

print "Referer         = ",cgi::Referer(),nl
print "Password        = ",Environ("HTTP_PASSWORD"),nl
print "Full auth string= ",Environ("HTTP_AUTHORIZATION"),nl
print "\nCookies:\n"
for i=1 to NumberOfCookies
  print "cookie" & i," ",cgi::Cookie("cookie" & i),"\n"
next i

print "Text field using Param(\"TEXT-FIELD\") is ",cgi::Param("TEXT-FIELD"),nl,nl


if cgi::RequestMethod() = "GET" then
  print "GET text field using GetParam(\"TEXT-FIELD\") is ",cgi::GetParam("TEXT-FIELD"),nl
end if

if cgi::RequestMethod() = "POST" then
  print "POST text field using PostParam(\"TEXT-FIELD\") is ",cgi::PostParam("TEXT-FIELD"),nl
  if cgi::ContentType() like "multipart*" then
    print "Original file name is ",cgi::FileName("FILE-UPLOAD-NAME"),nl
    if cgi::FileLength("FILE-UPLOAD-NAME") > 0 then
      print "File of length ",cgi::FileLength("FILE-UPLOAD-NAME")," bytes is saved\n"
      on error goto NoSave
      cgi::SaveFile "FILE-UPLOAD-NAME","/home/jrs/sb/upload.txt"
    else
      print "There is no uploaded file."
    end if
  end if
end if

print """</PRE><TABLE><TR><TD BORDER=0 BGCOLOR="EEEEEE"><PRE>
A simple form to POST parameters:<BR>
<FORM METHOD="POST" ACTION="/home/echo">
<INPUT TYPE="TEXT" VALUE="DEFAULT TEXT" NAME="TEXT-FIELD">
<INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" POST ">
</FORM>
</PRE></TD><TD BORDER=1 width="20">&nbsp;</TD><TD BORDER=0 BGCOLOR="EEEEEE"><PRE>
A simple form to GET parameters:<BR>
<FORM METHOD="GET" ACTION="/home/echo">
<INPUT TYPE="TEXT" VALUE="DEFAULT TEXT" NAME="TEXT-FIELD">
<INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" GET ">
</FORM>
</PRE></TD></TR></TABLE><PRE>
<hr>
</FORM>
</BODY>
</HTML>
"""
stop
NoSave:

print "An error has happened saving the file. Code =",error(),nl

resume next

9 (edited by ScriptBASIC 11/02/2015 01:46:12 am)

Re: Script BASIC

sbhttpd supports in memory sessions with static read/write lockable shared variables between threads and runs as a service.  If using ODBC for database access, connection pooling is supported. Appropriate extension modules used on the desktop are usable with sbhttpd.

I'm working on a php to Script BASIC translator but it's not a priority at the moment. I use Ultra Edit search and replace macros to do most of my php to SB conversion now.

I'm just about to release a QuickBooks Online connection to SuiteCRM running as SaaS with sbhttpd mirroring the QBO database in MySQL for instant access and unlimited users.  smile

10 (edited by apmuthu 11/02/2015 07:41:51 am)

Re: Script BASIC

Hence ScriptBASIC in it's final use case would be to replace the entire Apache/PHP/MySQL stack with a pure ScriptBASIC compiled (or intermediate compiled) alternative and no advantage in using both together.

What is it that can be done in ScriptBASIC that cannot be just as easily done in PHP?

The reason why PHP in general and FA in particular became popular is that it is in open text form and loosely typed and easy to program for the non programmer. "Protecting / Obfuscating" code will mitigate against the userbase. Proprietary code and compiled applications can hold users to ransom. Those who wish to retain independance in the code they use will run away from it! When acceptable alternatives like ScriptBASIC arrive, there must be a compelling reason to undertake a fresh learning curve and migrate to it.

With the arrival of Triggers, Procedures and Functions in MySQL, most PHP code can be replaced by them in getting logically directed computed storage done.

As your sbhttpd is a proxy, does it still depend on the availability of a real web server like Apache?

11 (edited by ScriptBASIC 11/02/2015 08:20:33 am)

Re: Script BASIC

apmuthu wrote:

Hence ScriptBASIC in it's final use case would be to replace the entire Apache/PHP/MySQL stack with a pure ScriptBASIC compiled (or intermediate compiled) alternative and no advantage in using both together.

sbhttpd is a proxy server. It only runs Script BASIC scripts. Apache handles the media, load levelling, security, ... and uses a mod_rewrite for communication with SB.

apmuthu wrote:

What is it that can be done in ScriptBASIC that cannot be just as easily done in PHP?

php is fine for a single instance application. It's resource heavy and interfacing with C is a PITA. Script BASIC works great as a cloud SaaS engine and glue to everything else.

apmuthu wrote:

The reason why PHP in general and FA in particular became popular is that it is in open text form and loosely typed and easy to program for the non programmer. "Protecting / Obfuscating" code will mitigate against the userbase. Proprietary code and compiled applications can hold users to ransom. Those who wish to retain independance in the code they use will run away from it! When acceptable alternatives like ScriptBASIC arrive, there must be a compelling reason to undertake a fresh learning curve and migrate to it.

BASIC is the basis for all other languages following it including php. If you don't know traditional BASIC than you shouldn't be able to to code in the first place.

apmuthu wrote:

With the arrival of Triggers, Procedures and Functions in MySQL, most PHP code can be replaced by them in getting logically directed computed storage done.

A simple Script BASIC MySQL example.

' MySQL Test Program

INCLUDE mysql.bas

dbh = mysql::RealConnect("localhost","root","the_password","classicmodels")

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

WHILE mysql::FetchHash(dbh,column)
  PRINT column{"productCode"}," - ",column{"productName"},"\n"
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)

Output

scriptbasic: ~/sb22/test $ time scriba testmysql.sb
S32_1268 - 1980s GM Manhattan Express
S32_1374 - 1997 BMW F650 ST
S32_2206 - 1982 Ducati 996 R
S32_2509 - 1954 Greyhound Scenicruiser
S32_3207 - 1950's Chicago Surface Lines Streetcar
S32_3522 - 1996 Peterbilt 379 Stake Bed with Outrigger
S32_4289 - 1928 Ford Phaeton Deluxe
S32_4485 - 1974 Ducati 350 Mk3 Desmo
S50_1341 - 1930 Buick Marquette Phaeton
S50_1392 - Diamond T620 Semi-Skirted Tanker
S50_1514 - 1962 City of Detroit Streetcar
S50_4713 - 2002 Yamaha YZR M1
S700_1138 - The Schooner Bluenose
S700_1691 - American Airlines: B767-300
S700_1938 - The Mayflower
S700_2047 - HMS Bounty
S700_2466 - America West Airlines B757-200
S700_2610 - The USS Constitution Ship
S700_2824 - 1982 Camaro Z28
S700_2834 - ATA: B757-300
S700_3167 - F/A 18 Hornet 1/72
S700_3505 - The Titanic
S700_3962 - The Queen Mary
S700_4002 - American Airlines: MD-11S
S72_1253 - Boeing X-32A JSF
S72_3212 - Pont Yacht
 
The database handle is: 1
Affected rows by SELECT: 110
Character set name is: latin1
Last error is:
Client info is: 5.5.44
Host info is: Localhost via UNIX socket
Proto info is: 10
Server info is: 5.5.44-0ubuntu0.14.04.1
PING result: -1
Thread ID: 0
Status is: Uptime: 5375236  Threads: 1  Questions: 19980  Slow queries: 0  Opens: 627  Flush tables: 1  Open tables: 400  Queries per second avg: 0.003

real    0m0.014s
user    0m0.004s
sys     0m0.002s
scriptbasic: ~/sb22/test $    
apmuthu wrote:

As your sbhttpd is a proxy, does it still depend on the availability of a real web server like Apache?

sbhttpd can run standalone for HTTP (non-media) based applications but typically it's a proxy to Apache.

Re: Script BASIC

@John: Thanks for the detailed info on ScriptBASIC. Just trying to find what part of C interfacing with FrontAccounting would need to justify using it.

MySQL interaction in a thread safe manner is the current way FA works with the MySQL server and that is as close as we get with C interaction with PHP and possibly no worse than ScriptBASIC. Hence any ScriptBASIC interfacing on the database side will not provide for any significant advantage especially if some form of cachiing (APC, memcached, etc) is used.

Interfacing with sensors for embedded applications where no php extension is available may be a use case for using PHP with ScriptBASIC.

If the recommended way to use ScriptBASIC is as a proxy to Apache and Apache runs on port 80 and the proxy runs on say port 8080, must the client then use port 8080 to access the application?

Re: Script BASIC

If the recommended way to use ScriptBASIC is as a proxy to Apache and Apache runs on port 80 and the proxy runs on say port 8080, must the client then use port 8080 to access the application?

Just standard access on port 80 for the user. In my example, anything out of /home is sbhttpd related.

Re: Script BASIC

Then would it mean that the proxy is to be used by the Apache conf file to manage folder paths selectively to enable sbhttpd to partake of port 80 as it's publicly accessible port and for PHP to partake of the real proxy port ( say port 8080 ) in it's interaction with ScriptBASIC?

Re: Script BASIC

I use the Apache config (sites-enabled) for the mod_rewrite additions pointing to the /home web directory to forward the request to the sbhttpd server.

Re: Script BASIC

Front Accounting is very well written and would be an easy port to Script BASIC due to everything being class based. I'm seriously thinking of porting it to Script BASIC to attract the Sage 100 (MAS90) crowd. They are Business BASIC centric so a FA in Script BASIC would make sense to them.

Re: Script BASIC

ScriptBASIC will then be replacing the entire PHP code with it's "compiled" version. A sort of a Desktop FA that has been done using  PHPDesktop earlier. FA updates would then need fresh compilations - nice business sense to sell "service"!

18 (edited by ScriptBASIC 11/03/2015 05:36:14 am)

Re: Script BASIC

Script BASIC is an interpreter like php. You can compile Script BASIC applications to C which allow statically linking in its C extensions modules.

I forgot the mention Script BASIC has a GUI desktop debugger/IDE and a remote socket based debugger that is great for debugging a client's web application.

I'll keep you in the loop if a Front Accounting php to Script BASIC port becomes a project.