Code:
5 PRINT "SVG sine wave"10 HTML20 PRINT "<svg width = '640' height = '480'>"30 FOR i = 1 TO 36040 PRINT "<rect x = '"; i / 360 * 320; "' y = '"; sin(i / 180 * 3.14) * 50 + 50; "' width = '1' height = '1' />"50 NEXT i60 PRINT "</svg>"
Code:
1 REM https://rosettacode.org/wiki/Draw_a_sphere5 PRINT "SVG sphere"10 HTML20 PRINT "<svg width = '640' height = '480'>"30 LET j = 240 FOR i = 221 TO 0 STEP j * -150 FOR k = -3.14 TO 3.14 STEP .0260 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 k90 LET j = j + 1100 NEXT i
Code:
1 REM https://rosettacode.org/wiki/Barnsley_fern5 PRINT "SVG Barnsley fern"10 HTML20 PRINT "<svg width = '640' height = '480' style = 'background-color:red;'>"30 FOR i = 1 TO 1000040 LET r = RND50 IF NOT(r > 0 AND r < .01) THEN 8060 LET x = .070 LET y = .16 * y80 IF NOT(r > .01 AND r < .08) THEN 11090 LET x = .22 * x - .26 * y100 LET y = -.23 * x + .22 * y + 1.6110 IF NOT(r > .075 AND r < .15) THEN 140120 LET x = .15 * x + .28 * y130 LET y = -.29 * x + .24 * y + .44140 LET x = .85 * x + .04 * y150 LET y = -.04 * x + .85 * y + 1.6160 LET x1 = (x + 3) * 70170 LET y1 = 700 - y * 70180 PRINT "<rect x = '"; x1; "' y = '"; y1; "' width = '1' height = '1' fill = 'green' />"190 NEXT i200 PRINT "</svg>"
Code:
1 REM https://rosettacode.org/wiki/Archimedean_spiral5 PRINT "SVG Archimedean spiral"10 HTML20 PRINT "<svg width = '640' height = '480'>"30 LET size = 8040 LET x = 25050 LET y = 20060 LET a = 1.570 LET b = .780 FOR t = 0 TO size * PI STEP .190 LET r = a + b * t100 PRINT "<rect x = '"; r * cos(t) + x; "' y = '"; r * sin(t) + y; "' width = '1' height = '1' />"110 NEXT t120 PRINT "</svg>"
Code:
5 PRINT "SVG curlicue"10 HTML20 PRINT "<svg width = '640' height = '480'>"30 FOR f = 0 TO 1000 STEP .140 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 f80 PRINT "</svg>"
Statistics: Posted by bongomeno — Thu Oct 05, 2023 9:25 pm
Code:
1 REM https://rosettacode.org/wiki/Attractive_numbers10 FOR x = 1 TO 12020 LET n = x30 LET c = 040 IF n MOD 2 <> 0 THEN 7050 LET n = INT(n / 2)60 LET c = c + 170 IF n MOD 2 = 0 THEN 4080 FOR i = 3 TO SQR(n) STEP 290 IF n MOD i <> 0 THEN 120100 LET n = INT(n / i)110 LET c = c + 1120 IF n MOD i = 0 THEN 90130 NEXT i140 IF n <= 2 THEN 160150 LET c = c + 1160 IF NOT(PRIME(c)) THEN 180170 PRINT x,180 NEXT x
Code:
1 REM https://rosettacode.org/wiki/Nth_root10 LET a = INT(RND * 5999) + 220 PRINT "nth root of "; a; "..."30 FOR n = 1 TO 1040 LET p = .0000150 LET x = a60 LET y = a / n70 IF ABS(x - y) <= p THEN 11080 LET x = y90 LET y = ((n - 1) * y + a / y ^ (n - 1)) / n100 IF ABS(x - y) > p THEN 80110 PRINT n; " : "; y120 NEXT n
Code:
1 REM https://rosettacode.org/wiki/Catalan_numbers10 LET @(0) = 120 FOR n = 0 TO 1530 LET p = n + 140 LET @(p) = 050 FOR i = 0 TO n60 LET q = n - i70 LET @(p) = @(p) + @(i) * @(q)80 NEXT i90 PRINT n; " "; @(n)100 NEXT n
Code:
1 REM https://rosettacode.org/wiki/Prime_decomposition10 LET loops = 10020 FOR x = 1 TO loops30 LET n = x40 PRINT n; " : ";50 LET c = 060 IF n MOD 2 > 0 THEN 11070 LET n = INT(n / 2)80 LET @(c) = 290 LET c = c + 1100 IF n MOD 2 = 0 THEN 70110 FOR i = 3 TO SQR(n) STEP 2120 IF n MOD i > 0 THEN 170130 LET n = INT(n / i)140 LET @(c) = i150 LET c = c + 1160 IF n MOD i = 0 THEN 130170 NEXT i180 IF n <= 2 THEN 210190 LET @(c) = n200 LET c = c + 1210 FOR y = 0 TO c220 IF @(y) = 0 THEN 250230 PRINT @(y); " ";240 LET @(y) = 0250 NEXT y260 PRINT270 NEXT x
Code:
1 REM Prime Table10 PRINT "Generating table of primes below..."20 HTML30 PRINT "<center><table><tr>"40 FOR y = 1 TO 5050 FOR x = 1 TO 2060 LET i = i + 170 PRINT "<td style = 'border:1px solid black; background-color:yellow;'>"80 PRINT i; ":<br /> "; PRIME(i)90 PRINT "</td>"100 NEXT x110 PRINT "</tr><tr>"120 NEXT y130 PRINT "</tr></table></center>"
Statistics: Posted by bongomeno — Thu Oct 05, 2023 1:37 am
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>
Statistics: Posted by bongomeno — Fri Sep 08, 2023 4:16 pm
Code:
1 REM USD currency conversion10 GET u20 PRINT "$"; u; " USD ="30 GET e40 GET g50 GET i60 GET j70 PRINT u * e; " EUR"80 PRINT u * g; " GBP"90 PRINT u * i; " INR"100 PRINT u * j; " JPY"
Statistics: Posted by bongomeno — Fri Sep 08, 2023 3:49 pm
Statistics: Posted by bongomeno — Fri Sep 08, 2023 1:59 pm
Also neatNow you may embed Net Basic apps on any site.
Statistics: Posted by MikeHawk — Fri Sep 08, 2023 10:14 am
Code:
1 REM Prime Table2 PRINT "Generating table of primes below..."5 HTML10 PRINT "<center><table><tr>";20 PRINT "<td style = 'border:1px solid black; background-color:yellow;'>";30 LET i = i + 140 LET b = b + 150 PRINT i; ":<br /> "; PRIME(i)60 PRINT "</td>";70 IF i = 1000 THEN 12080 IF b < 20 THEN 11090 LET b = 0100 PRINT "</tr><tr>";110 IF i < 1000 THEN 20120 PRINT "</tr></table></center>"
Statistics: Posted by bongomeno — Fri Sep 08, 2023 5:29 am
Code:
rand(0, getrandmax() - 1) / getrandmax()
Statistics: Posted by bongomeno — Fri Sep 08, 2023 1:29 am
Code:
rand(0, getrandmax() - 1) / getrandmax()
That said, I think I found something that you're not going to like much. I was about to say that a good alternative to NOT() is to use XOR -1... but... after running the following code in Net BASIC:Code:
10 PRINT 255 XOR -1
Code:
10 PRINT 16 AND 4
Code:
10 PRINT 5 AND 4
Code:
IF (15 AND 4) THEN PRINT (15 AND 5)
Code:
IF ((15 AND 4) <> 0) THEN PRINT ((15 AND 4) <> 0)
Code:
IF (15 ANDALSO 4) THEN PRINT (15 ANDALSO 4)
Code:
IF (flag1 AND 4) AND (flag2 AND 1) THEN...
Code:
IF 4 AND 1 THEN...
Statistics: Posted by MikeHawk — Wed Sep 06, 2023 5:17 pm
Code:
10 LET i = -1020 PRINT i, NOT(i)30 LET i = i + 140 IF i < 10 THEN 20
Code:
-10 9-9 8-8 7-7 6-6 5-5 4-4 3-3 2-2 1-1 00 -11 -22 -33 -44 -55 -66 -77 -88 -99 -10
Code:
case "!":$pointer--;//$evalstack[$pointer] = !intval($evalstack[$pointer]);if ($evalstack[$pointer] == ""){ $evalstack[$pointer] = "-1";}else{$evalstack[$pointer] = strval(floatval($evalstack[$pointer]) * -1 - 1);}$pointer++;break;
Statistics: Posted by bongomeno — Wed Sep 06, 2023 3:04 pm
This is due to my use of the PHP RND function. I need to write a custom RND function to return the same range as Qbasic.I also expected RND to return a value between 0 (included) and 1 (excluded) but got a very large integer instead. I assume it's an oversight, so I divided the result by 2^31. This one is a bit dirty, but it does the job:
Wow that game demo reminds me of Toki a bit. The language looks interesting I am going to study that a bit. Your code looks extremely well written and pretty advanced at a glance.Anyway, I tried designing scripting languages a few times; I usually have no issue with flow control (GOTO, GOSUB, RETURN, IF, ELSEIF, ELSE, ...) but I really can't write a proper way to evaluate stuff. The moment operators and variables get involved, it turns into some kind of Frankenstein monster of a language.
Kudos to you.
Statistics: Posted by bongomeno — Wed Sep 06, 2023 1:20 pm
Code:
IF (r < g) AND (r < b) THEN LET min = r
Code:
1 REM Silly egg puzzle10 LET floors = 5020 LET threshold = 1 + INT((RND / (2^31)) * floors)30 LET attempts = 040 PRINT "How many floors can an egg drop before it cracks? Find out using two eggs."100 REM First, try every [stride] floors.105 LET stride = INT(SQR(floors))110 LET throwFrom = 0115 PRINT "The test building is "; floors; " stories high, so we'll drop the 1st egg every "; stride; " floors."120 REM loop start125 LET attempts = attempts + 1130 IF (throwFrom >= threshold) THEN 150135 PRINT "1st egg survived floor "; throwFrom; "..."140 LET throwFrom = throwFrom + stride145 GOTO 120150 PRINT "1st egg cracked after being thrown from floor "; throwFrom; "!"200 LET throwFrom = throwFrom - stride + 1205 PRINT "Drop 2nd egg every floor, starting at "; throwFrom; "."210 REM loop start215 LET attempts = attempts + 1220 IF (throwFrom >= threshold) THEN 240225 PRINT "2nd egg survived floor "; throwFrom; "..."230 LET throwFrom = throwFrom + 1235 GOTO 210240 PRINT "2nd egg cracked after being thrown from floor "; throwFrom; "!"300 PRINT "The threshold was "; threshold; " and it was found in "; attempts ;" attempts."305 END
Statistics: Posted by MikeHawk — Wed Sep 06, 2023 8:45 am
Statistics: Posted by bongomeno — Tue Sep 05, 2023 11:08 pm
Code:
1 REM Get biggest common divisor of scrWidth and scrHeight (Euclidean Algorithm,) compute aspect ratio10 LET scrWidth = 102420 LET scrHeight = 76830 LET a = scrWidth40 LET b = scrHeight50 LET c = 0100 IF (scrWidth < scrHeight) THEN 130110 LET a = scrHeight120 LET b = scrWidth130 REM end if200 REM start loop (SWAP a, b)210 LET c = a220 LET a = b230 LET b = c250 REM another loop260 LET a = a - b270 IF (a >= b) THEN 250280 IF (a <> 0) THEN 200290 PRINT "The aspect ratio of "; scrWidth; "x"; scrHeight; " is "; scrWidth / b; ":"; scrHeight / b300 END
Code:
The aspect ratio of 1024x768 is 4:3
Code:
1 REM RGB (red green blue) to HSV (hue saturation value)10 LET r = 4920 LET g = 11830 LET b = 197100 REM lowest value105 IF (r < g) AND (r < b) THEN 125110 IF (g < r) AND (g < b) THEN 135115 LET min = b120 GOTO 200125 LET min = r130 GOTO 200135 LET min = g200 REM highest value205 IF (r > g) AND (r > b) THEN 225210 IF (g > r) AND (g > b) THEN 235215 LET max = b220 GOTO 300225 LET max = r230 GOTO 300235 LET max = g300 REM value305 LET v = max / 255400 IF (max = 0) THEN 440410 LET delta = max - min420 LET s = delta / max430 GOTO 500440 LET s = 0450 LET h = -1460 GOTO 1000500 IF (r = max) THEN 540510 IF (g = max) THEN 560520 LET h = 4 + (r - g) / delta530 GOTO 600540 LET h = (h - b) / delta550 GOTO 600560 LET h = 2 + (b - r) / delta600 LET h = h * 60610 IF (h >= 0) THEN 1000620 LET h = h + 3601000 PRINT "RGB("; r; " "; g; " "; b;") = HSV("; INT(h);"° "; INT(s*100);"% "; INT(v*100);"%)"1010 END
Code:
RGB(49 118 197) = HSV(212° 75% 77%)
Statistics: Posted by MikeHawk — Tue Sep 05, 2023 12:20 pm
Statistics: Posted by bongomeno — Fri Sep 01, 2023 8:30 pm