Active Forums => QB64 Discussion => Topic started by: Pete on July 27, 2019, 04:25:41 pm
Title: Your opinions needed...
Post by: Pete on July 27, 2019, 04:25:41 pm
Which s the best way to put a library together that requires the user to make their own prompts? One method uses DATA statements, like: DATA 123,456,EOF, while the other makes the user DIM the prompts variable and type: DIM Prompt$(20): Prompt$(0) = "abc": Prompt$(1) = "def", etc.
This is for a nice little "Notepad" with prompts program I made, which I would like to post as a library. The thing is, I only want to maintain one version.
Anyway, have a look here: https://www.qb64.org/forum/index.php?topic=1530.msg107504#msg107504
Both libraries allow you to make your own prompts, color the text window and text, type, cut, copy, paste, highlight, select all, and use the mouse as well as the keyboard to accomplish these tasks. I may even make another graphics version, using _putstring, in the future.
Pete
Title: Re: Your opinions needed...
Post by: SMcNeill on July 27, 2019, 04:51:47 pm
Generally, the way I do something like this is with 2 library files.
Do you have a link to one of your posted routines that shows that?
Pete
Here’s a link to one of Terry Richies: https://www.qb64.org/forum/index.php?topic=537.msg6476#msg6476
The start of that long set of code is all his TYPES, DECLARE statements, CONST, and global variables. Around line 272 is where you can see him REDIM SHARED several arrays with a 0 Index, as placeholders for ones the end-user will use in their own code.
Those declarations would be the BI file. The SUB/FUNCTION statements are the BM file, and you just place them on either side of your own work to use them, just like the simpler demo of my SaveImage Library: https://www.qb64.org/forum/index.php?topic=47.msg245#msg245
text$ ="Whatever the heck it is that we might want to compress, be that a long string of input, a binary file (just load the whole file into a single string and then deflate it), or whatever else is wanted)."
de$ = Deflate(text$)' <-- This is how simple it is to deflate the string
t$ = Inflate(de$)' <-- This is how simple it is to inflate that deflated string
'$include:'saveimage.bm'[/quote]
First lineis the include *.BI for the library. Last lineis the include *.BM file for the library. The users code just pops into the middle.
Title: Re: Your opinions needed...
Post by: bplus on July 28, 2019, 10:25:24 am
Here is my one successful test of using a library (for a challenge on another forum):
Title: Re: Your opinions needed...
Post by: Petr on July 28, 2019, 11:17:58 am
Hi, Pete. I would choose a DIM method, just as I do. This means that no matter how many text windows the user uses, simply counting the required number automatically with _PRESERVE - increases the number of places in the field without deleting the previous positions. As an example library ... I am adding a partially incomplete library for loading ANI files.