Author Topic: ScriptBasic - CompileOnline.com  (Read 4133 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic - CompileOnline.com
« on: September 27, 2013, 02:03:10 AM »


I'm happy to announce that ScriptBasic 2.2 CentOS 64 bit is available to run scripts online.

ScriptBasic Online

Note: I have tested the curl, sqlite, hash, t, gd SB extensions modules and they seem to work fine. MySQL/unixODBC isn't supported due to possible abuse. Files created with SB seem to be deleted after the session is exited. (you can download compiled projects before they're deleted)

I would like to thank Mohtashim (CompileOnline.com owner/developer) for his efforts getting ScriptBasic running on his site.
« Last Edit: September 28, 2013, 09:33:55 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic online word count example
« Reply #1 on: September 29, 2013, 06:36:33 PM »
I was looking for a way to load the files I needed to run a script on CompileOnline.com and modified my old word count code challenge script to adapt as an online utility.

Here the The Declaration of Independence of The United States of America by Thomas Jefferson in text format I used for my test.

Code: [Select]
http://www.constitution.org/usdeclar.txt
Code: [Select]
' Online word count script

IMPORT curl.bas

fname = COMMAND()

IF TRIM(fname) = "" THEN
  PRINT """
ScriptBasic Word Count Program
Usage: URL
   
"""
  END
END IF   

ch = curl::init()
curl::option(ch,"URL",fname)
curl::option(ch,"FILE","local_file.txt")
curl::perform(ch)
curl::finish(ch)

fsize = FILELEN("local_file.txt")
OPEN "local_file.txt" FOR INPUT AS #1
text = INPUT(fsize, #1)
CLOSE #1

strip = "()[]{}|<>/@0123456789*.,;:!#?%$&+=_~\"\\" & CHR(9) & CHR(10) & CHR(13)

FOR i = 1 TO LEN(strip)
  text = REPLACE(text, MID(strip, i, 1), " ")
NEXT i

SPLITA text BY " " TO word_list

OPEN "wc.raw" FOR OUTPUT AS #1

FOR x = 0 TO UBOUND(word_list)
  text_out = TRIM(word_list[x])
  IF LEN(text_out) THEN PRINT #1,LCASE(text_out),"\n"
NEXT x

CLOSE #1

ok = EXECUTE("sort wc.raw -o wc.srt", -1, PID)

OPEN "wc.srt" FOR INPUT AS #2

last_word = ""
word_count = 0
word_total = 0

Next_Word:

IF EOF(2) THEN GOTO Done

LINE INPUT #2, this_word

this_word = CHOMP(this_word)

word_total += 1

IF last_word = "" THEN last_word = this_word

IF this_word = last_word THEN
  word_count += 1
  GOTO Next_Word
END IF

PRINT last_word & " (" & word_count & ")\n"

last_word = this_word
word_count = 1

GOTO Next_Word 

Done:

PRINTNL

CLOSE #2

DELETE "wc.raw"
DELETE "wc.srt"
DELETE "local_file.txt"

END

Note: Enter the URL where the text document reside encapsulated with double quotes in the Command Line Arguments: text box.


« Last Edit: September 29, 2013, 11:53:35 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: ScriptBasic - CompileOnline.com
« Reply #2 on: September 29, 2013, 11:21:43 PM »
I modified the on-line word count program slightly to allow a minimum word count value to be displayed. If the optional count value isn't passed in the text box after the URL, then all words are shown. It looks like you don't need to use the double quotes around the URL either.

Code: [Select]
' Online word count script

IMPORT curl.bas

cmd_line = COMMAND()

IF TRIM(cmd_line) = "" THEN
  PRINT """
ScriptBasic Word Count Program
Usage: Usage: URL <minimum_word_count>
   
"""
  END
END IF   

SPLIT cmd_line BY " " TO fname, min_cnt
IF min_cnt < 1 THEN min_cnt = 1

ch = curl::init()
curl::option(ch,"URL",fname)
curl::option(ch,"FILE","local_file.txt")
curl::perform(ch)
curl::finish(ch)

fsize = FILELEN("local_file.txt")
OPEN "local_file.txt" FOR INPUT AS #1
text = INPUT(fsize, #1)
CLOSE #1

strip = "()[]{}|<>/@0123456789*.,;:!#?%$&+=_~\"\\" & CHR(9) & CHR(10) & CHR(13)

FOR i = 1 TO LEN(strip)
  text = REPLACE(text, MID(strip, i, 1), " ")
NEXT i

SPLITA text BY " " TO word_list   

OPEN "wc.raw" FOR OUTPUT AS #1

FOR x = 0 TO UBOUND(word_list)
  text_out = TRIM(word_list[x])
  IF LEN(text_out) THEN PRINT #1,LCASE(text_out),"\n"
NEXT x

CLOSE #1

ok = EXECUTE("sort wc.raw -o wc.srt", -1, PID)

OPEN "wc.srt" FOR INPUT AS #2

last_word = ""
word_count = 0
word_total = 0

Next_Word:

IF EOF(2) THEN GOTO Done

LINE INPUT #2, this_word

this_word = CHOMP(this_word)

word_total += 1

IF last_word = "" THEN last_word = this_word

IF this_word = last_word THEN
  word_count += 1
  GOTO Next_Word
END IF

IF word_count >= min_cnt THEN PRINT last_word & " (" & word_count & ")\n"

last_word = this_word
word_count = 1

GOTO Next_Word 

Done:

PRINTNL

CLOSE #2

DELETE "wc.raw"
DELETE "wc.srt"
DELETE "local_file.txt"

END

« Last Edit: September 29, 2013, 11:54:03 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic Online
« Reply #3 on: September 30, 2013, 09:52:32 PM »
ScriptBasic running on CompileOnline.com is not something new for SB. A manufacture of embedded ARM / POSIX controllers uses ScriptBasic and it's webserver in it's product for the last 8 or so years.







Charles Pegge wrote a MD5 routine in this version of SB that is a bit dated/crippled to say the least. (core SB features only - TCP/File is the only external IO)



Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic LIVE
« Reply #4 on: September 30, 2013, 11:42:06 PM »
I'm working on a ScriptBasic online Try Me addition to the ScriptBasic project site. I'm thinking of using the ACE editor like CompileOnline.com and a live SSH terminal applet to a chroot shell.




Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic Cloud9 IDE
« Reply #5 on: October 01, 2013, 02:22:04 AM »




Cloud9 IDE

Quote
Your code anywhere, anytime...

Write, run, and debug your code with our powerful and flexible cloud IDE. Collaborate on your workspaces publicly, or keep them private. The choice is yours!

FYI It works with BaCon as well.

« Last Edit: October 01, 2013, 02:26:31 AM by John »

kryton9

  • Guest
Re: ScriptBasic - CompileOnline.com
« Reply #6 on: October 01, 2013, 02:26:43 PM »
You are practicing dark magic here John. I need to check this cloud9 ide :)
Keep up the great work!

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic Online IDE
« Reply #7 on: October 01, 2013, 02:34:01 PM »
I'm a C9IDE paid subscriber and have some cool ideas for a collaborative online development initiative.  (SB dev, add-ons, code challenges, ...)

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic Cloud9 IDE
« Reply #8 on: October 01, 2013, 11:01:33 PM »
I have ScriptBasic running native on the Cloud9 IDE. (Red Hat 64 bit - Amazon EC2 instance) It's the best online development environment I have found to date. I have been using EC2 for sometime so the concept isn't all that new to me. (wish I thought of it)  >:( Hard to believe this is nothing more than a JavaScript application.
« Last Edit: October 01, 2013, 11:06:06 PM by John »