Sample programs

Joined: December 21st, 2016, 6:44 pm

June 10th, 2018, 1:50 am #1

I'm trying to get back into RFO Basic!. I've downloaded basic-launcher-npp but there are no sample files. I'm trying to create a simple slideshow app, so I need to be able to display images from jpeg files installed on the tablet.

I've had apps working before (a few years ago) so I just need to brush up on how to do things.
Thanks in advance
Quote
Like
Share

Joined: September 29th, 2017, 11:23 am

June 10th, 2018, 8:39 am #2

I don't know what that launcher is, but any version of any of the forks of RFO-BASIC! will contain dozens of sample files. However, it does not create the rfo-basic/ directory, and the subdirectories including Sample_Programs, when you sideload the APK file, but only the first time you run it.

There is also a branch of this Forum in which users have shared programs they have written: shared-basic-programs-f6/

You might benefit from a tutorial on RFO-BASIC! graphics that I wrote, especially on loading, resizing, and cropping images: https://rfobasic.miraheze.org/wiki/Graphics
Quote
Like
Share

Joined: December 21st, 2016, 6:44 pm

June 10th, 2018, 9:49 pm #3

Hi Spike
I downloaded  basic-launcher-npp from http://mougino.free.fr/rfo-basic/ to my PC. I ran rfo-basic-npp+pc-launcher.exe. It didn't install any sample programs. I uninstalled the app and ran the downloaded exe again. It still didn't install any sample programs. Where else can I download RFO Basic from?
Thanks
Quote
Like
Share

Joined: December 21st, 2016, 6:44 pm

June 10th, 2018, 10:07 pm #4

It's OK. I found the sample programs on my tablet!! 
Quote
Like
Share

Joined: December 21st, 2016, 6:44 pm

June 11th, 2018, 11:59 pm #5

I've got my slideshow program working but it seems as if there's a limit on the number of bitmaps per screen. After executing the following 26 times

gr.bitmap.load img, myfile$          % installed with RFO Basic

gr.bitmap.draw bp, img, 0,0     %position

I get the error "Invalid bitmap pointer". If I catch the error, close the graphics screen and reopen it, it goes for another 26 then fails after 2. myfile$ is a different image file each time (read from an array)
What am I doing wrong please?
Quote
Like
Share

Joined: December 21st, 2016, 6:44 pm

June 12th, 2018, 12:29 am #6

slideshow.bas (812 Bytes)





slideshow.bas (812 Bytes)
Quote
Like
Share

Joined: September 29th, 2017, 11:23 am

June 12th, 2018, 6:53 am #7

Oh, that is an easy one. Your loop does not include GR.CLS. Therefore, every time through the loop, you are loading new bitmaps, until you run out of memory. Clear the screen, regenerate the screen, re-render with GR.RENDER.

However, there may be greater efficiencies, such as loading the bitmaps once only and not having to reload them, or not even regenerating the screen but just using GR.MODIFY to make elements move around or hide/reappear.

Do read at least the Intro of the document I recommended in #2 above.
Quote
Like
Share

Joined: December 21st, 2016, 6:44 pm

June 12th, 2018, 7:40 pm #8

Thanks Spike. I'm sorry I didn't read your tutorial fully. 

I have now implemented all I could glean from your tutorial but it still has the same issue. My code now has


GR.cls
pause 500
gr.bitmap.load img, myfile$       
gr.bitmap.draw bp, img, 0,0     %position
Gr.render

but it still fails after 25 images. I am running Ice Cream Sandwich on an old Bauhn tablet so maybe it's an issue of lack of memory. I realise I could load the bitmaps just once from the files but I don't want to do that at this stage. The code I have now provides an adequate workaround so I won't trouble you any more.

Thanks again
Quote
Like
Share

Joined: September 29th, 2017, 11:23 am

June 12th, 2018, 9:14 pm #9

Ron, the GR.BITMAP.DRAW statement creates an element in the Object List, and bp is an index to that object. GR.CLS clears the Object List and GR.RENDER renders all the elements. By comparison, GR.BITMAP.LOAD copies bytes from the storage device to Android memory (assigning it the handle "img"), and GR.CLS does not clear this; only GR.BITMAP.DELETE does. (In the fork called OLI-BASIC, "GR.CLS 1" clears these too.)

I think your code will work if you move GR.BITMAP.LOAD outside the loop, and I think it will load and load and load until it runs out of memory if you keep GR.BITMAP.LOAD inside the loop.

(Edited: Upon further review, this is explained in the third paragraph of 6. Bitmaps in my tutorial.)
Quote
Like
Share

Joined: November 21st, 2013, 7:00 pm

June 14th, 2018, 2:19 am #10

You could try this (untested);

GR.cls
pause 500
If img>0 then gr.bitmap.delete img
gr.bitmap.load img, myfile$ % new img
gr.bitmap.draw bp, img, 0,0 %position
Gr.render
- Failure is not an option. It is bundled with the software. -
Quote
Like
Share