[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2023-10-05T21:25:15-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/14901 2023-10-05T21:25:15-05:00 2023-10-05T21:25:15-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39362#p39362 <![CDATA[Re: Net Basic - a BASIC in PHP]]>
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 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>"
Program encoded URL: https://www.lucidapogee.com/netbasic/?l ... Fsvg%3E%22

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
Program encoded URL: https://www.lucidapogee.com/netbasic/?l ... %20i%0D%0A

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>"
Program encoded URL: https://www.lucidapogee.com/netbasic/?l ... Fsvg%3E%22

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>"
Program encoded URL: https://www.lucidapogee.com/netbasic/?l ... Fsvg%3E%22

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>"
Program encoded URL: https://www.lucidapogee.com/netbasic/?l ... Fsvg%3E%22

Statistics: Posted by bongomeno — Thu Oct 05, 2023 9:25 pm


]]>
2023-10-05T01:37:33-05:00 2023-10-05T01:37:33-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39361#p39361 <![CDATA[Re: Net Basic - a BASIC in PHP]]> They are detailed in the documentation.

Examples are updated to reflect the update.

A few New/updated examples:

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


]]>
2023-09-08T16:16:54-05:00 2023-09-08T16:16:54-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39360#p39360 <![CDATA[Re: Net Basic - a BASIC in PHP]]> 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>

Statistics: Posted by bongomeno — Fri Sep 08, 2023 4:16 pm


]]>
2023-09-08T15:49:10-05:00 2023-09-08T15:49:10-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39359#p39359 <![CDATA[Re: Net Basic - a BASIC in PHP]]>
The GET command is an advanced feature intended to be used with URL encoded programs. The command returns the contents of a variable with the same name from the URL. Variable names must be upper case in the URL.

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

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"
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 ... Y%22%0D%0A

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

Statistics: Posted by bongomeno — Fri Sep 08, 2023 3:49 pm


]]>
2023-09-08T13:59:29-05:00 2023-09-08T13:59:29-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39358#p39358 <![CDATA[Re: Net Basic - a BASIC in PHP]]>
I did write a BASIC to ASM compiler called FTCBASIC, but it's very limited with only unsigned ints. It only has DO/LOOPS and ENDIF. I wouldn't mind trying to write an even better compiler or at least improving the one I already started.

Statistics: Posted by bongomeno — Fri Sep 08, 2023 1:59 pm


]]>
2023-09-08T10:14:08-05:00 2023-09-08T10:14:08-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39357#p39357 <![CDATA[Re: Net Basic - a BASIC in PHP]]>
Works perfectly. Always greater than 0 and less than 1. I updated your egg dropping example to reflect the change.
Neat! :D
Now you may embed Net Basic apps on any site. 8)
Also neat :shock:

If you did not already: check out Ethan Winer's BASIC Techniques and Utilities Book, it explains a lot of things about BASIC code optimization, hardware, and algorithms, but it also covers compiled BASIC code early on (that is, how BASIC is converted into assembly.) It's a hefty book (475 pages) and I'm not expecting you to read it cover to cover (I did not,) but check out the 1st chapter (pages 9 to 20.) There's also a good section on bit operations (page 48 and 49.) The following page, Ethan explains control flow. He starts with DO... LOOP and how it is converted to assembly.
The reason why I think it could be beneficial is because assembly doesn't contain many instructions; once you got those tiny elemental bricks going, you can write a pseudo-compiler to execute your code. Once you got the GOTO down, you can work on conditional jumping. And once you got this, you're gravy: it unlocks the path to condition blocks (like IF... ELSEIF... ELSE... ENDIF,) and loops (like FOR... NEXT and DO... LOOP.) It's a truly amazing read.

Statistics: Posted by MikeHawk — Fri Sep 08, 2023 10:14 am


]]>
2023-09-08T05:29:37-05:00 2023-09-08T05:29:37-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39356#p39356 <![CDATA[Re: Net Basic - a BASIC in PHP]]>

For example:

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>"
generates this url

https://www.lucidapogee.com/netbasic/?l ... E%22%0D%0A

Look closely at the URL and you will see encoded BASIC. Click it to run the program. The interpreter decoded and executes these links taking the full page without displaying the editor. The URL is like an executable format for the interpreter.

Remote scripting in BASIC with GET requests... oh yeahhh..

Now you may embed Net Basic apps on any site. 8)

Statistics: Posted by bongomeno — Fri Sep 08, 2023 5:29 am


]]>
2023-09-08T01:29:44-05:00 2023-09-08T01:29:44-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39355#p39355 <![CDATA[Re: Net Basic - a BASIC in PHP]]>

Code:

rand(0, getrandmax() - 1) / getrandmax()
Changed. Works perfectly. Always greater than 0 and less than 1. I updated your egg dropping example to reflect the change.

I tried all sorts of stuff to try making it work like QBasic, but ultimately I decided it was out of the scope of what I am trying to do. I reverted everything to work like YaBasic, Just Basic, and PHP.

1 is true and 0 is false
this applies to all operator and functions

1 and 1 equals 1
not(0) equals 1
not(1) equals 0
etc..

I also had to fix some other issues. Hopefully I didn't create more in the process. 8)

Statistics: Posted by bongomeno — Fri Sep 08, 2023 1:29 am


]]>
2023-09-06T17:17:44-05:00 2023-09-06T17:17:44-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39354#p39354 <![CDATA[Re: Net Basic - a BASIC in PHP]]>

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
It returned 255 instead of -256... I got a little worried so I tried something else:

Code:

10 PRINT 16 AND 4
But it returned -1 when I expected it to return 0.

Code:

10 PRINT 5 AND 4
Also returned -1 when it should have returned 4.

>Problem is Qbasic gives other values than just -1 and 1 depending on the number.
The thing is that QBasic's boolean operators are not conditional. Basically, it's the difference between "&" and "&&" in C and JavaScript (or "AND" and "ANDALSO" in FreeBASIC:) "&" is used as a boolean operator to mask bits (16 AND 16 returns 16, but 16 AND 32 returns 0,) while "&&" is a conditional logical operator that only returns TRUE if the two operands are not null. When QB evaluates something like:

Code:

IF (15 AND 4) THEN PRINT (15 AND 5)
It evaluates 4 (not -1.) However:

Code:

IF ((15 AND 4) <> 0) THEN PRINT ((15 AND 4) <> 0)
Evaluates -1. And in FreeBASIC:

Code:

IF (15 ANDALSO 4) THEN PRINT (15 ANDALSO 4)
Would also evaluate -1.
Basically, IF only executes when the result is not null... or, it jumps to another (hidden) label and skips whatever code is supposed to happen if the evaluation is null.

I remember a long time ago I couldn't understand why this evaluation never worked:

Code:

IF (flag1 AND 4) AND (flag2 AND 1) THEN...
I expected that if the value flag1 had its 3rd bit set and flag2 had its 1st bit set, then the condition would trigger. It never did because QB solved it as:

Code:

IF 4 AND 1 THEN...
Which is 0.

Statistics: Posted by MikeHawk — Wed Sep 06, 2023 5:17 pm


]]>
2023-09-06T15:04:33-05:00 2023-09-06T15:04:33-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39352#p39352 <![CDATA[Re: Net Basic - a BASIC in PHP]]>
The three examples by MikeHawk have been added.

Based on the issue I described in the post above, I decided to change how the NOT() works for now. Let me know if this is bad.

Code:

10 LET i = -1020 PRINT i, NOT(i)30 LET i = i + 140 IF i < 10 THEN 20
Returns

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
Now identical to QBasic.. except for when floating point values are used. I don't know what to do with that. I know the newer languages have a more optimal version of NOT, but I wanted this to be a classic BASIC like language.

This is what I am doing in PHP:

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;
The commented out line is what I started with.

Statistics: Posted by bongomeno — Wed Sep 06, 2023 3:04 pm


]]>
2023-09-06T13:20:25-05:00 2023-09-06T13:20:25-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39351#p39351 <![CDATA[Re: Net Basic - a BASIC in PHP]]>
IIRC, Net Basic didn't throw an error when I attempted to do:

Code: Select all

IF (r < g) AND (r < b) THEN LET min = r

It failed and after looking into the sample codes, I understood I had to jump instead. But I expected an error at least.
I have not yet figured out how to support that (haven't tried much either) or the combining of lines with a colon. I will add else/endif instead. My parser is "different" than most proper ones. It just splits the text as it goes.

I have not made any effort to implement error checking yet. My plan is to do that last by studying the errors in other Tiny BASIC implementations. For now I need to update the documentation to specify that combining statements with IF or : is not supported.
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:
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.

Another issue is that PHP returns 1 for true as opposed to -1 like QBasic (I noticed YaBasic also returns a 1). I made functions return -1 and changed AND and OR to return -1 on true. The problem comes with NOT(). I don't know how to make it return the same values as QBasic. Right now it will return a 1 on true. I need to change that to make it return -1 to be consistent. Problem is Qbasic gives other values than just -1 and 1 depending on the number. Oh the decisions....
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.
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.

The expression evaluation stuff has always been out of my reach, so a little over a year ago I decided to dedicate my life to figuring it out and now here I am. My methods are different, but seem to work. What helped me was studying Reverse Polish Notation. You must convert infix notation to postfix, then evaluate the postfix. This wasn't too hard with just four arithmetic operators. The parenthesis are processed and removed during the infix to postfix phase. I was really stumped on things like boolean and relops. Variables weren't too hard. Functions took some creative gutsy attempts. The arrays are still a struggle too.

I'd be happy to share what I have learned about expression evaluation if needed. I can pull up some of the resources that I had studied. TBH it was a bunch of old college class assignments, calculator websites, and RPN tutorials.

Statistics: Posted by bongomeno — Wed Sep 06, 2023 1:20 pm


]]>
2023-09-06T08:45:02-05:00 2023-09-06T08:45:02-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39350#p39350 <![CDATA[Re: Net Basic - a BASIC in PHP]]>
May I include your snippets in the Net Basic examples?
Sure, go ahead.

IIRC, Net Basic didn't throw an error when I attempted to do:

Code:

IF (r < g) AND (r < b) THEN LET min = r
It failed and after looking into the sample codes, I understood I had to jump instead. But I expected an error at least.

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:

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
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.
TRASH.RAR

Statistics: Posted by MikeHawk — Wed Sep 06, 2023 8:45 am


]]>
2023-09-05T23:08:11-05:00 2023-09-05T23:08:11-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39349#p39349 <![CDATA[Re: Net Basic - a BASIC in PHP]]> I'm glad you were able to get the thing to work. It's scary putting stuff like this out not knowing what kind of errors people will find. Always seems like I miss things.

Your snippets are perfect for the scope of what I intended this BASIC for. Demonstrating concepts with code online.

What's funny is I set the language up to use var names a-z with 0-9 like Tiny Basics. Yet, your examples work perfectly. This is probably due to my usage of SESSION for variables. As a result, I double checked to make sure this was okay internally and updated the documentation of the page. PHP has been very different for me.

May I include your snippets in the Net Basic examples?

It really is a throwback writing IF logic with line jumps. My plan is to add FOR/TO/STEP/NEXT/BREAK first. Then GOSUB/RETURN. Eventually I plan to add ELSE/ENDIF. It will take me a while to get there.

The part I'm not so confident about is the INPUT statement. There needs to be a way to store the running program in a SESSION. I already am using SESSION for the variables, code, and code execution position. After some failed attempts, I just need more time.

Statistics: Posted by bongomeno — Tue Sep 05, 2023 11:08 pm


]]>
2023-09-05T12:20:05-05:00 2023-09-05T12:20:05-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39348#p39348 <![CDATA[Re: Net Basic - a BASIC in PHP]]>

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
And the output was of course:

Code:

The aspect ratio of 1024x768 is 4:3
I also tried this one:

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
And got

Code:

RGB(49 118 197) = HSV(212° 75% 77%)
Condition blocks spoiled me, it took me way too long to remember the GW-Basic way of doing things. :lol:

Statistics: Posted by MikeHawk — Tue Sep 05, 2023 12:20 pm


]]>
2023-09-06T15:38:10-05:00 2023-09-01T20:30:41-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=39347#p39347 <![CDATA[Net Basic - a BASIC in PHP]]>

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

I started the project earlier this week. It's stable and live. Try it out.

https://lucidapogee.com/netbasic

Statistics: Posted by bongomeno — Fri Sep 01, 2023 8:30 pm


]]>