News:

Welcome to RetroCoders Community

Main Menu

My 1st BAM snippet

Started by Lucidapogee, Aug 22, 2023, 02:21 AM

Previous topic - Next topic

Lucidapogee

1 'https://rosettacode.org/wiki/Babbage_problem
10 PRINT "calculating..."
20 LET n = 2
30 DO
40 LET n = n + 2
50 LOOP UNTIL (n ^ 2) MOD 1000000 = 269696
60 PRINT "The smallest number whose square ends in 269696 is: "; n
70 PRINT "It's square is "; n * n

I wanted to try BAM, so I ported a simple bit of code.

It's saved under Babbage_problem.

It was simple to port as your language is QB friendly.

BAM worked nicely on my Windows XP sp3 netbook. I will work on porting more code to BAM.

CharlieJV

Really?  Good stuff!

In case you didn't run into this tidbit yet:

BAM is a TiddlyWiki instance.  Like any TiddlyWiki, a press of the save button will download the single HTML file to wherever you want it (locally, wherever).

Whatever programs you create in there, they just become part of that TiddlyWiki.  When you want to save your work, you don't save the individual programs, but rather you download (via the save button) the entire TiddlyWiki instance, overwriting the previous version or creating another instance with a different save name.

For folk unfamiliar with that stuff, it can take a bit getting used to.

If you run into any problems, give me a shout.

Me, I'm a career Gupta Team Developer programmer for Windows applications with Oracle back-ends.

Programming for Windows has and is my bread and butter, but my household is Chromebooks only.

Online or offline, having a BASIC that runs in a browser was a necessity, hence BASIC Anywhere Machine.

And being able to get old programs from the 70's and 80's running again and easily shared: woohoo!

CharlieJV

Quote from: Lucidapogee on Aug 22, 2023, 02:21 AMIt's saved under Babbage_problem.


Wait a minute.  Delayed reaction here.

Saved under "Babbage_problem".  You don't mean saved to my hosted BAM version, do you?

Because nobody can save there.  That's just a static file server.

If you haven't yet, check out:



Lucidapogee

It seems I need to watch the video.

I thought when I press save as that it was visible to everyone.

CharlieJV

Quote from: Lucidapogee on Aug 22, 2023, 03:02 AMIt seems I need to watch the video.

I thought when I press save as that it was visible to everyone.

Yeah, it just dawns on me now that anybody could easily think that.

BAM is just one HTML page, a "client-side browser app".  There's a whole bunch of stuff in that one page (a whole lot of javascript), but just one page.

So no interaction with any server (like saving something you edit on Wikipedia, which requires the web page talking with a server).




CharlieJV


Lucidapogee

#6
Ok, I watched the video this time. Using the check button, I saved a local copy and retyped the snippet. I saved the snippet and changed my username, then closed and reopened the local copy. All seems to have been saved and is working fine.

 I will post the snippet in the OP, this way it may be shared. Now I will need to work on more. Although it may take me some time as I'm working on a big release.

Reddit links don't work for me as I don't have an account. It says the content is not reviewed and I have to log in to see it.

Lucidapogee

ok, here's another quick one. I call it the Matrix effect.

COLOR 2

matrix:

        LOCATE INT(RND * 25) + 1, INT(RND * 80) + 1
        PRINT INT(RND * 2)

GOTO matrix

CharlieJV

Quote from: Lucidapogee on Aug 23, 2023, 07:24 PMOk, I watched the video this time. Using the check button, I saved a local copy and retyped the snippet. I saved the snippet and changed my username, then closed and reopened the local copy. All seems to have been saved and is working fine.

Good stuff!  Let me know if anything was clear as mud.

The audio on that video is really low: my knee-jerk reaction, swinging too far the other way, when somebody told me the whistling sound (when I pronounce any S) is really annoying.

CharlieJV

Quote from: Lucidapogee on Aug 23, 2023, 07:24 PMReddit links don't work for me as I don't have an account. It says the content is not reviewed and I have to log in to see it.

When I right-click on that Reddit link and choose to open that in "incognito" mode, it gives me a view of the post for folk who aren't signed in.  I was able to view the whole post (had to click on a "Read More" link to see the whole post, including comments), run the program and view the source code.

Not sure why that wouldn't work for you.  If I think of something, I'll get back to you.


CharlieJV

#10
Quote from: Lucidapogee on Aug 23, 2023, 07:52 PMmatrix:        LOCATE INT(RND * 25) + 1, INT(RND * 80) + 1        PRINT INT(RND * 2) GOTO matrix

Man, I do enjoy, something silly, interesting programs that have few lines of code.  EDIT: a blast to just sit back and watch.

BTW, anything involving infinite (or otherwise very long) loops, I highly recommend putting one of the following in the loop:

_DELAY 0.001

or

SLEEP 0.001


The BASIC code gets turned into javascript, and once javascript gets into an infinite loop, it is easy for the program to completely lock up the browser tab/window, as it doesn't get out of that loop to check for events that would stop the program.

PRINT sometimes seems to sometimes prevent a program from locking up in an endless loop, but I don't know if that is consistent.
       

Lucidapogee

Quote from: CharlieJV on Aug 23, 2023, 08:10 PM
Quote from: Lucidapogee on Aug 23, 2023, 07:24 PMOk, I watched the video this time. Using the check button, I saved a local copy and retyped the snippet. I saved the snippet and changed my username, then closed and reopened the local copy. All seems to have been saved and is working fine.

Good stuff!  Let me know if anything was clear as mud.

The audio on that video is really low: my knee-jerk reaction, swinging too far the other way, when somebody told me the whistling sound (when I pronounce any S) is really annoying.

It was a lot of info at once, but I got it after watching twice.

I'll go ahead and use the _delay. Isn't that more precise than sleep?


CharlieJV

Quote from: Lucidapogee on Aug 23, 2023, 08:31 PM
Quote from: CharlieJV on Aug 23, 2023, 08:10 PM
Quote from: Lucidapogee on Aug 23, 2023, 07:24 PMOk, I watched the video this time. Using the check button, I saved a local copy and retyped the snippet. I saved the snippet and changed my username, then closed and reopened the local copy. All seems to have been saved and is working fine.

Good stuff!  Let me know if anything was clear as mud.

The audio on that video is really low: my knee-jerk reaction, swinging too far the other way, when somebody told me the whistling sound (when I pronounce any S) is really annoying.

It was a lot of info at once, but I got it after watching twice.

I'll go ahead and use the _delay. Isn't that more precise than sleep?



Not in BAM.  The two are interchangeable, the way I've implemented them.  Both available to cover GW-BASIC programs and QB64 programs.

Lucidapogee

Okay makes sense. The matrix program in qb1.1 or qb4.5 works best with no delay to get full speed and you can crash the console window easily. Even without the delay, my browser handled it well. No freezing. BAM did the matrix effect accurately.