Net Basic is a minimal BASIC dialect contained in an online programming environment that is suitable for performing complex calculations on the go.

HTTPS access: https://www.lucidapogee.com/netbasic
HTTP access: http://www.http.lucidapogee.com/netbasic

Notable features include:

- Write code interactively online anytime
- Syntax inspired by Dartmouth, Palo Alto, and Altair
- Free and hosted online to run your scripts 24/7
- Source may be compiled into program encoded URLs
- Has ability to output html and interact with GET requests
- Plenty of examples available to get started
- Support forum available to ask questions or share creations
- No javascript or ads present on page
- Purely written in PHP
- Available for https and http browsers

A direct interpreter hosted on the web. You submit code and get results. There's no input, but GET requests may be read to allow url variables and forms.

The expression evaluation routines behind this calculator are essentially the same as other projects I am working on. Net Basic is closed source for now.

If anyone finds problems with something, please let me know so I may try making improvements.

Net Basic support forum: https://lucidapogee.com/forum/viewforum.php?f=36

If you're interested in an open source BASIC interpreter, then check out Craft Basic for Windows 95 and up and Tiny Craft Basic for DOS. Craft Basic is written in Emergence Basic and Tiny Craft Basic is written in Quick Basic.
Here's a link to the Windows version of Craft Basic: https://lucidapogee.com/index.php?page=craftbasic
Here's a link to Tiny Craft Basic for DOS: https://lucidapogee.com/forum/viewtopic.php?t=4
My compiler FTCBASIC for DOS utilizes FASM and is open source: https://lucidapogee.com/index.php?page=ftcbasic

Here's some examples to look at. Below each example is a program encoded URL. Click the each URL to run the examples.


Code:

1 REM https://rosettacode.org/wiki/Attractive_numbers
10 FOR x = 1 TO 120
20 LET n = x
30 LET c = 0
40 IF n MOD 2 <> 0 THEN 70
50 LET n = INT(n / 2)
60 LET c = c + 1
70 IF n MOD 2 = 0 THEN 40
80 FOR i = 3 TO SQR(n) STEP 2
90 IF n MOD i <> 0 THEN 120
100 LET n = INT(n / i)
110 LET c = c + 1
120 IF n MOD i = 0 THEN 90
130 NEXT i
140 IF n <= 2 THEN 160
150 LET c = c + 1
160 IF NOT(PRIME(c)) THEN 180
170 PRINT x,
180 NEXT x

Program encoded url: https://www.lucidapogee.com/netbasic/?listing=1%20REM%20https%3A%2F%2Frosettacode.org%2Fwiki%2FAttractive_numbers%0D%0A10%20FOR%20x%20%3D%201%20TO%20120%0D%0A20%20LET%20n%20%3D%20x%0D%0A30%20LET%20c%20%3D%200%0D%0A40%20IF%20n%20MOD%202%20%3C%3E%200%20THEN%2070%0D%0A50%20LET%20n%20%3D%20INT%28n%20%2F%202%29%0D%0A60%20LET%20c%20%3D%20c%20%2B%201%0D%0A70%20IF%20n%20MOD%202%20%3D%200%20THEN%2040%0D%0A80%20FOR%20i%20%3D%203%20TO%20SQR%28n%29%20STEP%202%0D%0A90%20IF%20n%20MOD%20i%20%3C%3E%200%20THEN%20120%0D%0A100%20LET%20n%20%3D%20INT%28n%20%2F%20i%29%0D%0A110%20LET%20c%20%3D%20c%20%2B%201%0D%0A120%20IF%20n%20MOD%20i%20%3D%200%20THEN%2090%0D%0A130%20NEXT%20i%0D%0A140%20IF%20n%20%3C%3D%202%20THEN%20160%0D%0A150%20LET%20c%20%3D%20c%20%2B%201%0D%0A160%20IF%20NOT%28PRIME%28c%29%29%20THEN%20180%0D%0A170%20PRINT%20x%2C%0D%0A180%20NEXT%20x


Code:

1 REM https://rosettacode.org/wiki/Nth_root
10 LET a = INT(RND * 5999) + 2
20 PRINT "nth root of "; a; "..."
30 FOR n = 1 TO 10
40 LET p = .00001
50 LET x = a
60 LET y = a / n
70 IF ABS(x - y) <= p THEN 110
80 LET x = y
90 LET y = ((n - 1) * y + a / y ^ (n - 1)) / n
100 IF ABS(x - y) > p THEN 80
110 PRINT n; " : "; y
120 NEXT n

Program encoded url: https://www.lucidapogee.com/netbasic/?listing=10%20LET%20a%20%3D%20INT%28RND%20%2A%205999%29%20%2B%202%0D%0A20%20PRINT%20%22nth%20root%20of%20%22%3B%20a%3B%20%22...%22%0D%0A30%20FOR%20n%20%3D%201%20TO%2010%0D%0A40%20LET%20p%20%3D%20.00001%0D%0A50%20LET%20x%20%3D%20a%0D%0A60%20LET%20y%20%3D%20a%20%2F%20n%0D%0A70%20IF%20ABS%28x%20-%20y%29%20%3C%3D%20p%20THEN%20110%0D%0A80%20LET%20x%20%3D%20y%0D%0A90%20LET%20y%20%3D%20%28%28n%20-%201%29%20%2A%20y%20%2B%20a%20%2F%20y%20%5E%20%28n%20-%201%29%29%20%2F%20n%0D%0A100%20IF%20ABS%28x%20-%20y%29%20%3E%20p%20THEN%2080%0D%0A110%20PRINT%20n%3B%20%22%20%3A%20%22%3B%20y%0D%0A120%20NEXT%20n


Code:

1 REM https://rosettacode.org/wiki/Prime_decomposition
10 LET loops = 100
20 FOR x = 1 TO loops
30 LET n = x
40 PRINT n; " : ";
50 LET c = 0
60 IF n MOD 2 > 0 THEN 110
70 LET n = INT(n / 2)
80 LET @(c) = 2
90 LET c = c + 1
100 IF n MOD 2 = 0 THEN 70
110 FOR i = 3 TO SQR(n) STEP 2
120 IF n MOD i > 0 THEN 170
130 LET n = INT(n / i)
140 LET @(c) = i
150 LET c = c + 1
160 IF n MOD i = 0 THEN 130
170 NEXT i
180 IF n <= 2 THEN 210
190 LET @(c) = n
200 LET c = c + 1
210 FOR y = 0 TO c
220 IF @(y) = 0 THEN 250
230 PRINT @(y); " ";
240 LET @(y) = 0
250 NEXT y
260 PRINT
270 NEXT x

Program encoded url: https://www.lucidapogee.com/netbasic/?listing=1%20REM%20https%3A%2F%2Frosettacode.org%2Fwiki%2FPrime_decomposition%0D%0A10%20LET%20loops%20%3D%20100%0D%0A20%20FOR%20x%20%3D%201%20TO%20loops%0D%0A30%20LET%20n%20%3D%20x%0D%0A40%20PRINT%20n%3B%20%22%20%3A%20%22%3B%0D%0A50%20LET%20c%20%3D%200%0D%0A60%20IF%20n%20MOD%202%20%3E%200%20THEN%20110%0D%0A70%20LET%20n%20%3D%20INT%28n%20%2F%202%29%0D%0A80%20LET%20%40%28c%29%20%3D%202%0D%0A90%20LET%20c%20%3D%20c%20%2B%201%0D%0A100%20IF%20n%20MOD%202%20%3D%200%20THEN%2070%0D%0A110%20FOR%20i%20%3D%203%20TO%20SQR%28n%29%20STEP%202%0D%0A120%20IF%20n%20MOD%20i%20%3E%200%20THEN%20170%0D%0A130%20LET%20n%20%3D%20INT%28n%20%2F%20i%29%0D%0A140%20LET%20%40%28c%29%20%3D%20i%0D%0A150%20LET%20c%20%3D%20c%20%2B%201%0D%0A160%20IF%20n%20MOD%20i%20%3D%200%20THEN%20130%0D%0A170%20NEXT%20i%0D%0A180%20IF%20n%20%3C%3D%202%20THEN%20210%0D%0A190%20LET%20%40%28c%29%20%3D%20n%0D%0A200%20LET%20c%20%3D%20c%20%2B%201%0D%0A210%20FOR%20y%20%3D%200%20TO%20c%0D%0A220%20IF%20%40%28y%29%20%3D%200%20THEN%20250%0D%0A230%20PRINT%20%40%28y%29%3B%20%22%20%22%3B%0D%0A240%20LET%20%40%28y%29%20%3D%200%0D%0A250%20NEXT%20y%0D%0A260%20PRINT%0D%0A270%20NEXT%20x


Code:

1 REM Prime Table
10 PRINT "Generating table of primes below..."
20 HTML
30 PRINT "<center><table><tr>"
40 FOR y = 1 TO 50
50 FOR x = 1 TO 20
60 LET i = i + 1
70 PRINT "<td style = 'border:1px solid black; background-color:yellow;'>"
80 PRINT i; ":<br /> "; PRIME(i)
90 PRINT "</td>"
100 NEXT x
110 PRINT "</tr><tr>"
120 NEXT y
130 PRINT "</tr></table></center>"

Program encoded url: https://www.lucidapogee.com/netbasic/?listing=1%20REM%20Prime%20Table%0D%0A10%20PRINT%20%22Generating%20table%20of%20primes%20below...%22%0D%0A20%20HTML%0D%0A30%20PRINT%20%22%3Ccenter%3E%3Ctable%3E%3Ctr%3E%22%0D%0A40%20FOR%20y%20%3D%201%20TO%2050%0D%0A50%20FOR%20x%20%3D%201%20TO%2020%0D%0A60%20LET%20i%20%3D%20i%20%2B%201%0D%0A70%20PRINT%20%22%3Ctd%20style%20%3D%20%27border%3A1px%20solid%20black%3B%20background-color%3Ayellow%3B%27%3E%22%0D%0A80%20PRINT%20i%3B%20%22%3A%3Cbr%20%2F%3E%20%22%3B%20PRIME%28i%29%0D%0A90%20PRINT%20%22%3C%2Ftd%3E%22%0D%0A100%20NEXT%20x%0D%0A110%20PRINT%20%22%3C%2Ftr%3E%3Ctr%3E%22%0D%0A120%20NEXT%20y%0D%0A130%20PRINT%20%22%3C%2Ftr%3E%3C%2Ftable%3E%3C%2Fcenter%3E%22

Take this simple program and encode it to a url using the IDE on the Net Basic page.

Code:

1 REM USD currency conversion
10 GET u
20 PRINT "$"; u; " USD ="
30 GET e
40 GET g
50 GET i
60 GET j
70 PRINT u * e;  " EUR"
80 PRINT u * g; " GBP"
90 PRINT u * i; " INR"
100 PRINT u * j; " JPY"



Once you get the url, add the variables to the url in upper case. Notice the U=25.99&E=.925881&G=.7924&I=82.628&J=145.96 part.

Here's the URL ready to go: https://www.lucidapogee.com/netbasic/?U=25.99&E=.925881&G=.7924&I=82.628&J=145.96&listing=1%20REM%20USD%20currency%20conversion%0D%0A10%20GET%20u%0D%0A20%20PRINT%20%22%24%22%3B%20u%3B%20%22%20USD%20%3D%22%0D%0A30%20GET%20e%0D%0A40%20GET%20g%0D%0A50%20GET%20i%0D%0A60%20GET%20j%0D%0A70%20PRINT%20u%20*%20e%3B%20%20%22%20EUR%22%0D%0A80%20PRINT%20u%20*%20g%3B%20%22%20GBP%22%0D%0A90%20PRINT%20u%20*%20i%3B%20%22%20INR%22%0D%0A100%20PRINT%20u%20*%20j%3B%20%22%20JPY%22%0D%0A
(for some reason the link broke, so you will have to copy/paste this one for it to work)

When you click the link, you will get exchange rates. Simply modify the GET variables to change the program output.


Try saving this form as a .html file and open it with your browser.
You will have a currency conversion app on your screen.

Code:

<form action = "https://www.lucidapogee.com/netbasic/" target = "output" method = "get">
<p>
U<br /><input type = "text" name = "U" value = "1"><br />
E<br /><input type = "text" name = "E" value = ".925881"><br />
G<br /><input type = "text" name = "G" value = ".7924"><br />
I<br /><input type = "text" name = "I" value = "82.628"><br />
J<br /><input type = "text" name = "J" value = "145.96">
</p>
<input type = "hidden" name = "listing" value = "1%20REM%20USD%20currency%20conversion%0D%0A10%20GET%20u%0D%0A20%20PRINT%20%22%24%22%3B%20u%3B%20%22%20USD%20%3D%22%0D%0A30%20GET%20e%0D%0A40%20GET%20g%0D%0A50%20GET%20i%0D%0A60%20GET%20j%0D%0A70%20PRINT%20u%20*%20e%3B%20%20%22%20EUR%22%0D%0A80%20PRINT%20u%20*%20g%3B%20%22%20GBP%22%0D%0A90%20PRINT%20u%20*%20i%3B%20%22%20INR%22%0D%0A100%20PRINT%20u%20*%20j%3B%20%22%20JPY%22%0D%0A">
<input type = "submit">
</form>
<iframe name = "output"></iframe>


I realized that Net Basic could generate graphics by printing HTML with SVG tags. I'm still figuring out how to use SVG and what's possible, but for now I went ahead and made some SVG examples.

To use SVG in Net Basic, first call the HTML command to break from the text output area.


Code:

5 PRINT "SVG sine wave"
10 HTML
20 PRINT "<svg width = '640' height = '480'>"
30 FOR i = 1 TO 360
40 PRINT "<rect x = '"; i / 360 * 320; "' y = '"; sin(i / 180 * 3.14) * 50 + 50; "' width = '1' height = '1' />"
50 NEXT i
60 PRINT "</svg>"

Program encoded URL: https://www.lucidapogee.com/netbasic/?listing=5%20PRINT%20%22SVG%20sine%20wave%22%0D%0A10%20HTML%0D%0A20%20PRINT%20%22%3Csvg%20width%20%3D%20%27640%27%20height%20%3D%20%27480%27%3E%22%0D%0A30%20FOR%20i%20%3D%201%20TO%20360%0D%0A40%20PRINT%20%22%3Crect%20x%20%3D%20%27%22%3B%20i%20%2F%20360%20%2A%20320%3B%20%22%27%20y%20%3D%20%27%22%3B%20sin%28i%20%2F%20180%20%2A%203.14%29%20%2A%2050%20%2B%2050%3B%20%22%27%20width%20%3D%20%271%27%20height%20%3D%20%271%27%20%2F%3E%22%0D%0A50%20NEXT%20i%0D%0A60%20PRINT%20%22%3C%2Fsvg%3E%22


Code:

1 REM https://rosettacode.org/wiki/Draw_a_sphere
5 PRINT "SVG sphere"
10 HTML
20 PRINT "<svg width = '640' height = '480'>"
30 LET j = 2
40 FOR i = 221 TO 0 STEP j * -1
50 FOR k = -3.14 TO 3.14 STEP .02
60 PRINT "<rect x = '"; 221 + i * sin(k); "' y = '"; 222 + 221 * cos(k); "' width = '1' height = '1' />"
70 PRINT "<rect x = '"; 221 + 221 * sin(k); "' y = '"; 222 + (i - 1) * cos(k); "' width = '1' height = '1' />"
80 NEXT k
90 LET j = j + 1
100 NEXT i

Program encoded URL: https://www.lucidapogee.com/netbasic/?listing=1%20REM%20https%3A%2F%2Frosettacode.org%2Fwiki%2FDraw_a_sphere%0D%0A5%20PRINT%20%22SVG%20sphere%22%0D%0A10%20HTML%0D%0A20%20PRINT%20%22%3Csvg%20width%20%3D%20%27640%27%20height%20%3D%20%27480%27%3E%22%0D%0A30%20LET%20j%20%3D%202%0D%0A40%20FOR%20i%20%3D%20221%20TO%200%20STEP%20j%20%2A%20-1%0D%0A50%20FOR%20k%20%3D%20-3.14%20TO%203.14%20STEP%20.02%0D%0A60%20PRINT%20%22%3Crect%20x%20%3D%20%27%22%3B%20221%20%2B%20i%20%2A%20sin%28k%29%3B%20%22%27%20y%20%3D%20%27%22%3B%20222%20%2B%20221%20%2A%20cos%28k%29%3B%20%22%27%20width%20%3D%20%271%27%20height%20%3D%20%271%27%20%2F%3E%22%0D%0A70%20PRINT%20%22%3Crect%20x%20%3D%20%27%22%3B%20221%20%2B%20221%20%2A%20sin%28k%29%3B%20%22%27%20y%20%3D%20%27%22%3B%20222%20%2B%20%28i%20-%201%29%20%2A%20cos%28k%29%3B%20%22%27%20width%20%3D%20%271%27%20height%20%3D%20%271%27%20%2F%3E%22%0D%0A80%20NEXT%20k%0D%0A90%20LET%20j%20%3D%20j%20%2B%201%0D%0A100%20NEXT%20i%0D%0A


Code:

1 REM https://rosettacode.org/wiki/Barnsley_fern
5 PRINT "SVG Barnsley fern"
10 HTML
20 PRINT "<svg width = '640' height = '480' style = 'background-color:red;'>"
30 FOR i = 1 TO 10000
40 LET r = RND
50 IF NOT(r > 0 AND r < .01) THEN 80
60 LET x = .0
70 LET y = .16 * y
80 IF NOT(r > .01 AND r < .08) THEN 110
90 LET x = .22 * x - .26 * y
100 LET y = -.23 * x + .22 * y + 1.6
110 IF NOT(r > .075 AND r < .15) THEN 140
120 LET x = .15 * x + .28 * y
130 LET y = -.29 * x + .24 * y + .44
140 LET x = .85 * x + .04 * y
150 LET y = -.04 * x + .85 * y + 1.6
160 LET x1 = (x + 3) * 70
170 LET y1 = 700 - y * 70
180 PRINT "<rect x = '"; x1; "' y = '"; y1; "' width = '1' height = '1' fill = 'green' />"
190 NEXT i
200 PRINT "</svg>"

Program encoded URL: https://www.lucidapogee.com/netbasic/?listing=1%20REM%20https%3A%2F%2Frosettacode.org%2Fwiki%2FBarnsley_fern%0D%0A5%20PRINT%20%22SVG%20Barnsley%20fern%22%0D%0A10%20HTML%0D%0A20%20PRINT%20%22%3Csvg%20width%20%3D%20%27640%27%20height%20%3D%20%27480%27%20style%20%3D%20%27background-color%3Ared%3B%27%3E%22%0D%0A30%20FOR%20i%20%3D%201%20TO%2010000%0D%0A40%20LET%20r%20%3D%20RND%0D%0A50%20IF%20NOT%28r%20%3E%200%20AND%20r%20%3C%20.01%29%20THEN%2080%0D%0A60%20LET%20x%20%3D%20.0%0D%0A70%20LET%20y%20%3D%20.16%20%2A%20y%0D%0A80%20IF%20NOT%28r%20%3E%20.01%20AND%20r%20%3C%20.08%29%20THEN%20110%0D%0A90%20LET%20x%20%3D%20.22%20%2A%20x%20-%20.26%20%2A%20y%0D%0A100%20LET%20y%20%3D%20-.23%20%2A%20x%20%2B%20.22%20%2A%20y%20%2B%201.6%0D%0A110%20IF%20NOT%28r%20%3E%20.075%20AND%20r%20%3C%20.15%29%20THEN%20140%0D%0A120%20LET%20x%20%3D%20.15%20%2A%20x%20%2B%20.28%20%2A%20y%0D%0A130%20LET%20y%20%3D%20-.29%20%2A%20x%20%2B%20.24%20%2A%20y%20%2B%20.44%0D%0A140%20LET%20x%20%3D%20.85%20%2A%20x%20%2B%20.04%20%2A%20y%0D%0A150%20LET%20y%20%3D%20-.04%20%2A%20x%20%2B%20.85%20%2A%20y%20%2B%201.6%0D%0A160%20LET%20x1%20%3D%20%28x%20%2B%203%29%20%2A%2070%0D%0A170%20LET%20y1%20%3D%20700%20-%20y%20%2A%2070%0D%0A180%20PRINT%20%22%3Crect%20x%20%3D%20%27%22%3B%20x1%3B%20%22%27%20y%20%3D%20%27%22%3B%20y1%3B%20%22%27%20width%20%3D%20%271%27%20height%20%3D%20%271%27%20fill%20%3D%20%27green%27%20%2F%3E%22%0D%0A190%20NEXT%20i%0D%0A200%20PRINT%20%22%3C%2Fsvg%3E%22


Code:

1 REM https://rosettacode.org/wiki/Archimedean_spiral
5 PRINT "SVG Archimedean spiral"
10 HTML
20 PRINT "<svg width = '640' height = '480'>"
30 LET size = 80
40 LET x = 250
50 LET y = 200
60 LET a = 1.5
70 LET b = .7
80 FOR t = 0 TO size * PI STEP .1
90 LET r = a + b * t
100 PRINT "<rect x = '"; r * cos(t) + x; "' y = '"; r * sin(t) + y; "' width = '1' height = '1' />"
110 NEXT t
120 PRINT "</svg>"

Program encoded URL: https://www.lucidapogee.com/netbasic/?listing=1%20REM%20https%3A%2F%2Frosettacode.org%2Fwiki%2FArchimedean_spiral%0D%0A5%20PRINT%20%22SVG%20Archimedean%20spiral%22%0D%0A10%20HTML%0D%0A20%20PRINT%20%22%3Csvg%20width%20%3D%20%27640%27%20height%20%3D%20%27480%27%3E%22%0D%0A30%20LET%20size%20%3D%2080%0D%0A40%20LET%20x%20%3D%20250%0D%0A50%20LET%20y%20%3D%20200%0D%0A60%20LET%20a%20%3D%201.5%0D%0A70%20LET%20b%20%3D%20.7%0D%0A80%20FOR%20t%20%3D%200%20TO%20size%20%2A%20PI%20STEP%20.1%0D%0A90%20LET%20r%20%3D%20a%20%2B%20b%20%2A%20t%0D%0A100%20PRINT%20%22%3Crect%20x%20%3D%20%27%22%3B%20r%20%2A%20cos%28t%29%20%2B%20x%3B%20%22%27%20y%20%3D%20%27%22%3B%20r%20%2A%20sin%28t%29%20%2B%20y%3B%20%22%27%20width%20%3D%20%271%27%20height%20%3D%20%271%27%20%2F%3E%22%0D%0A110%20NEXT%20t%0D%0A120%20PRINT%20%22%3C%2Fsvg%3E%22


Code:

5 PRINT "SVG curlicue"
10 HTML
20 PRINT "<svg width = '640' height = '480'>"
30 FOR f = 0 TO 1000 STEP .1
40 LET x = x + SIN(f * f)
50 LET y = y + COS(f * f)
60 PRINT "<rect x = '"; x; "' y = '"; y; "' width = '1' height = '1' />"
70 NEXT f
80 PRINT "</svg>"

Program encoded URL: https://www.lucidapogee.com/netbasic/?listing=5%20PRINT%20%22SVG%20curlicue%22%0D%0A10%20HTML%0D%0A20%20PRINT%20%22%3Csvg%20width%20%3D%20%27640%27%20height%20%3D%20%27480%27%3E%22%0D%0A30%20FOR%20f%20%3D%200%20TO%201000%20STEP%20.1%0D%0A40%20LET%20x%20%3D%20x%20%2B%20SIN%28f%20%2A%20f%29%0D%0A50%20LET%20y%20%3D%20y%20%2B%20COS%28f%20%2A%20f%29%0D%0A60%20PRINT%20%22%3Crect%20x%20%3D%20%27%22%3B%20x%3B%20%22%27%20y%20%3D%20%27%22%3B%20y%3B%20%22%27%20width%20%3D%20%271%27%20height%20%3D%20%271%27%20%2F%3E%22%0D%0A70%20NEXT%20f%0D%0A80%20PRINT%20%22%3C%2Fsvg%3E%22
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement