Suggestion
BlitzMax Forums/BlitzMax Programming/Suggestion
| ||
No, this is not a bug report, it's a suggestion for BlitzMAX. I did not see a forum folder for suggestions - so - here you go. I am seeing several people contributing source, especially in asking questions on how to get their code to work. One problem I am seeing is that their source includes paths and media links that are not present. One thing that could be done to get around this would be have a special mode in BlitzMAX where a list of all lines of code in BlitzMAX where media is being listed for loading: loadimage, loadpixmap, loadsound, loadimagefont, etc. Have these lines appear as a list and let the programmer choose from a set of default internal images or audio to appear instead in their place so the program can run the source without error. Some default images might be triangles, squares, circles, or other simple objects. Some default audio might be single note pitches or warbles. It would not modify the source code in the least and you could always use a checkmark [X] beside each of the selections to use an internal media or if it's not checkmarked, then it will try to load the actual media. This would greatly speed up the debugging process for people who download other peoples' source codes that have no media in them. |
| ||
Great idea dw817 Does someone fancy taking up the challenge and rewriting BlitzMax,and the IDE. :) Do ppl really sit there stoned and naked reading the Blitz Forums.:) |
| ||
So you're proposing that someone spend hours and hours of effort to remedy something that should be addressed by the person that posted the code in the first place. If the code snippet is not accompanied in some way (link to a download, embedded DefData statements etc.) by all of the media necessary to run it, then the person posting said snippet is an ignorant (in the academic sense) in asking for support in programming forums, where the protocol is to ask for help with the smallest reproducible example of the problem in question. |
| ||
Well Kryzon / Blitzman, I might even be able to write a program to do this, but my code would directly modify the source so you would need to back it up first. I was just thinking out loud - trying some people's demos they posted in the forums when they have questions - and finding quite a few of them hard-linking to files that just aren't there. Kinna defeating the ability to run them and to see what problems they are having. |
| ||
Sounds a bit involved for running code of a forum though ;) You could just as well make a custom TStreamFactory that takes an encoded string as input. Kinda like inline data urls in html. And with a support binary to encode files to that specification, put it in a module and it would just be an import away. Might be easier to get something like that into mainline bmx too. |
| ||
Not knowing what a TStreamFactory is, Grable. Can you elaborate please ? |
| ||
Its a protocol for handling different stream "types". There is already ones defined for http, sockets, unicode, ramstreams and endianness.LoadText("http::www.google.com")The part before :: is the protocol type, which selects which factory that loads/interprets the data. |
| ||
Ah, gotcha. I sorta knew you could download websites as text files, but not that easily. (filing away in my brain for future use).Local a$=LoadText("http::www.google.com") Print Len(a$)So, do you want someone to then upload some simple pictures Online and then have the code change from a hardcoded image that is not there to instead load from these Online addresses ? |
| ||
No, im proposing an "inline-base64" factory, that simply decodes the url/path as base64 (or any other text encoding). Not touching the filesystem at all. |
| ||
If I'm reading (the Google definition) this correctly, do you mean something like this ? http://www.blitzbasic.com/Community/post.php?topic=105558&post=1289297 Notice how I am not really loading an image but text data that builds an image: ocal img_alen:TImage=img8Load("15db2f92","800")If you don't mean that, color me confused. Could you please post an example, Grable ? |
| ||
Im not sure what encoding that is, looks like hex? Anyway, it would be similar yes. Just using a standard text encoding and be usable by all functions taking streams/url objects. |
| ||
It's 8-characters hex value 0-15 each character to generate an 8x8 single-color image. It's a little quick & dirty way I can get game sprites in a hurry. You are mentioning URL, can you please post some example code of an inline-base 64 image load, Grable ? |
| ||
I havent got any sample code im afraid. And what i mean by "stream/url object" is just the convention of blitzmax LoadXXX taking a type of Object not just a String. Its so that one can pass another TStream, good for chaining streams and such. |
| ||
Are you then wanting to load an image from a URL ? That can be done today in BlitzMAX if you want to see the code. |
| ||
The only reason i called it "url" was because that is the name blitzmax uses for its argument for load functions. So no, i dont need to see any code ;) On another note, ive been trying to port some base64 to bmx without much luck, none of them produce accurate results! (notably FreePascal has some nice streams, though the code isnt pretty) Im probably too tired so my brain must be failing hard hehe. Going to bed and il see what happens tomorrow :) |
| ||
By base64 do you mean a program to convert 8-bit data to 6-bit and back again ? ... and yes, it's late. I'm going to get to bed here in about a half hour myself, Grable. :) |
| ||
Base64 > https://en.wikipedia.org/wiki/Base64 |
| ||
While Brucey (timid as always) only links to Wiki, I link to Bruceys module: https://github.com/maxmods/bah.mod/blob/master/base64.mod/base64.bmx It contains helpers for decoding/encoding + a simple (commented out) sample how to encode/decode bas64. But I do not know if dw' would use that code - it is 210 lines of code for something other "languages" provide inbuild. If you "optimize" Brucey's code the needed LOC will decrease by a big amount (line wise, not characters wise). bye Ron |
| ||
I linked to wikipedia because he doesn't know what base64 is, and the page provides a good explanation. The module assumes you already know that you want to use base64 encoding/decoding. :-) |
| ||
Oh, I already wrote this, Ron and Brucey. I guess I just didn't know what it was called. http://www.blitzbasic.com/Community/post.php?topic=105555&post=1288567 http://www.blitzbasic.com/Community/post.php?topic=105555&post=1288492 |
| ||
Finally got some time to get things to work, this is straight from wikipedia, so not optimized one bit ;) I see you already had something similar, but il post it here anyway for future reference. Try the sample and marvel at my mad drawing skills! EDIT: Id like to go further though, and make a stream that does encoding/decoding on the fly, which should make it faster. Some other day perhaps. GRB.Base64 GRB.Base64Stream test.bmx |
| ||
This is going to sound silly, Grable. How do I compile your "Module GRB.Base64Stream " ? I try and get, Compile Error - Modules does not match commandline module. |
| ||
Put them into : mod/grb.mod/base64stream.mod/base64.mod/base64.bmx mod/grb.mod/base64stream.mod/base64stream.mod/base64stream.bmx Alternatively store both as "base64.bmx" and "base64stream.bmx" in your project folder base64.bmx: Remove the line "Module GRB.Base64" base64stream.bmx: "Module GRB.Base64Stream" base64stream.bmx: replace "Import GRB.Base64" with 'Import "base64.bmx"' test.bmx: replace "Import GRB.Base64Stream" with 'Import "base64stream.bmx"' --- Another option is to copy the "functional" code lines of "base64.bmx" and "base64stream.bmx" in one single file (potentially even in your project.bmx-file - there is no need to have it done as "module". bye Ron |
| ||
But them into : mod/grb.mod/base64.mod/base64.bmx mod/grb.mod/base64stream.mod/base64stream.bmx Alternatively store both as "base64.bmx" and "base64stream.bmx" in your project folder base64.bmx: Remove the line "Module GRB.Base64" base64stream.bmx: "Module GRB.Base64Stream" base64stream.bmx: replace "Import GRB.Base64" with 'Import "base64.bmx"' test.bmx: replace "Import GRB.Base64Stream" with 'Import "base64stream.bmx"' --- Another option is to copy the "functional" code lines of "base64.bmx" and "base64stream.bmx" in one single file (potentially even in your project.bmx-file - there is no need to have it done as "module". bye Ron |
| ||
No, making them accessible as a MOD is something I need to learn, Ron. Okay, I went to my \mod\ directory and made a new directory there called, "GRB.mod." inside that directory I placed the two *.bmx files, Base64.bmx and Base64Stream.bmx in there. ![]() Then I tried to run the demo (from above) test.bmx and it still crashes. |
| ||
Quoting my own: Put them into : mod/grb.mod/base64.mod/base64.bmx mod/grb.mod/base64stream.mod/base64stream.bmx So you do not put the *.bmx-files in "mod/GRB.mod" but in "mod/GRB.mod/base64stream.mod/.." and "mod/GRB.mod/base64.mod/..." Why? Both bmx files are written as individual modules. Of course you could copy the functions of the base64.bmx-file to the base64stream.bmx-code and you only have 1 module then ... play around with it to get the desired learn effect. bye Ron |
| ||
You're missing additional folders 'base64stream.mod'. Look at the directory structure Derron posted, read them with attention. EDIT: Ninja-ed by Derron |
| ||
Let me try this ... Nope, still crashing, here is the current directory layout so far, decided to use a tree viewer so it can be pinpointed:![]() Put them into : mod/grb.mod/base64.mod/base64.bmx mod/grb.mod/base64stream.mod/base64stream.bmx As requested. I even shut down BlitzMAX and brought it back up. Still receiving error message: Compile Error - Can't find interface for module 'grb.base64stream' for this code: |
| ||
You need to compile the modules. Bruceys bmk.exe does this automatically. The original one ...not. Either recompile all modules via maxide...or from commandline. Commandline: blitzmax/bin/bmk.exe makemods -a grb.mod (or just grb? ... replying from phone so I cannot check that). Bye Ron |
| ||
bmk makemods grb.base64 bmk makemods grb.base64stream bmk makemods -h grb.base64 bmk makemods -h grb.base64streamShould do the trick. -h is for threaded mode, not strictly needed unless you use it though. |
| ||
Good job, Grable ! That's precisely what I needed, a working example. I went to DOS SHELL and from the BIN directory, typed that out, returned, tried to run the program and - IT CRASHED AGAIN ! *Grin* So I SHUT DOWN BlitzMAX, brought it back up, =RERAN= it, and it executed just fine, and that's very interesting what you did - you can call a custom library from inside a file URL, that was the real thing I wanted to see in the demo. Thanks for the assistance Ron. :) |
| ||
Happy to help dw817 :) |