Author Topic: Samples/Toolbox re-awakening. Call for entries.  (Read 9668 times)

0 Members and 1 Guest are viewing this topic.

Offline The Librarian

  • Newbie
  • Posts: 39
    • View Profile
Samples/Toolbox re-awakening. Call for entries.
« on: August 10, 2019, 08:49:24 pm »
As the topic says, it's time we expand our Samples Gallery and Toolbox. Please reply to this post with links to existing threads in Programs with code that qualifies.

First things first though - is everyone happy with the filled circle/ellipse code up there?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #1 on: August 10, 2019, 09:20:08 pm »
Here is a link to a number of tools:
https://www.qb64.org/forum/index.php?topic=1511.0

First, I have been very happy with filled circle and ellipse code actually has come in handy for me, thanks!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #2 on: August 10, 2019, 09:29:12 pm »
ConvertOffset: http://qb64.freeforums.net/thread/52/convert-offset-integer64

MEMSort: http://qb64.freeforums.net/thread/28/mem-sort

ExtendedTimer: http://qb64.freeforums.net/thread/20/extended-timer-uet

SaveImage: (needs updated on forums to the latest version and then linked)

POSIX File and Dir Listing to Arrays: http://qb64.freeforums.net/thread/63/file-directory-listing-arrays

Spell Checker: https://www.qb64.org/forum/index.php?topic=1587.0

MemToHex: https://www.qb64.org/forum/index.php?topic=1553.0

All of the above are handy little routines which I keep in my toolbox and have reused in a ton of different ways.




https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #3 on: August 11, 2019, 04:39:32 am »
Thanks boys.

I happen to know the Librarian connects through a mobile hotspot so updates may a bit slow.

The old "saveimage" routine is a gem Steevo! Resurrect that for us, I bet the newbies will be thrilled!
You're not done when it works, you're done when it's right.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #4 on: August 11, 2019, 05:53:25 am »
Not sure where to begin this discussion, but may as well be here.

So MEM is different than all QB64 commands, amirite? It's strange from a QB45 point of view, takes a minute to master from a QB64 point of view, and I've noticed that almost half of Steve's tools involve it.

So the question is, should we cram MEM-related stuff into its own category? Something all-inclusive to MEM, including tutorials. It may be sortof a turnoff to see all the MEM stuff scattered into everything else. --- OR, is this 100% off base? ... because Toolbox entries should be black boxes that shouldnt be looked into... hmmm... opinions?
You're not done when it works, you're done when it's right.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #5 on: August 11, 2019, 06:05:13 am »
Hi. I am again last.


Please look to my previous answer  https://www.qb64.org/forum/index.php?topic=1566.msg107875#msg107875

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #6 on: August 11, 2019, 06:09:15 am »
As the topic says, it's time we expand our Samples Gallery and Toolbox. Please reply to this post with links to existing threads in Programs with code that qualifies.

First things first though - is everyone happy with the filled circle/ellipse code up there?

I'm curious as to what 'code that qualifies' means :) Is there a criteria to me met?
Loading Signature...

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #7 on: August 11, 2019, 06:16:02 am »
Quote
I'm curious as to what 'code that qualifies' means :) Is there a criteria to me met?

You got it m8.

https://www.qb64.org/forum/index.php?topic=178.0

https://www.qb64.org/forum/index.php?topic=1062.0
You're not done when it works, you're done when it's right.

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #8 on: August 11, 2019, 06:33:08 am »
You got it m8.

https://www.qb64.org/forum/index.php?topic=178.0

https://www.qb64.org/forum/index.php?topic=1062.0

Thank you. Looks like I probably don't comment my code enough to qualify. I'd submit this but I didn't post the source code in the thread and it was all spaghetti anyways :)
Loading Signature...

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #9 on: August 11, 2019, 08:07:49 am »
Not sure where to begin this discussion, but may as well be here.

So MEM is different than all QB64 commands, amirite? It's strange from a QB45 point of view, takes a minute to master from a QB64 point of view, and I've noticed that almost half of Steve's tools involve it.

So the question is, should we cram MEM-related stuff into its own category? Something all-inclusive to MEM, including tutorials. It may be sortof a turnoff to see all the MEM stuff scattered into everything else. --- OR, is this 100% off base? ... because Toolbox entries should be black boxes that shouldnt be looked into... hmmm... opinions?

_MEM really isn’t that strange; it’s QB64’s updated take on PEEK and POKE.  Since “toolboxes” tend to contain those routines which you use over and over again, they tend to be as efficient as possible, so they’ll plug into any program — and you can’t beat the speed and performance of direct memory access I Which MEM gives.  I think a lot of toolbox code will make use of MEM, when it can.  Probably no reason to separate them into their own subfolder. ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #10 on: August 11, 2019, 09:04:19 am »
Not sure where to begin this discussion, but may as well be here.

So MEM is different than all QB64 commands, amirite? It's strange from a QB45 point of view, takes a minute to master from a QB64 point of view, and I've noticed that almost half of Steve's tools involve it.

So the question is, should we cram MEM-related stuff into its own category? Something all-inclusive to MEM, including tutorials. It may be sortof a turnoff to see all the MEM stuff scattered into everything else. --- OR, is this 100% off base? ... because Toolbox entries should be black boxes that shouldnt be looked into... hmmm... opinions?

Categories would be great!

Who wants to look for a saw in the sandpaper pile or a screwdriver in metric socket sets?

But can this be done on a forum? 0f course it can, if there is a Will to do it!  ;-)

If categories are by function, MEM routines would span many categories for a speedier way to do a numbers crunching task, is my thought.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #11 on: August 11, 2019, 09:18:36 am »
For my first official submission I would like to present Split1000:

We worked on this a bit here at the forum this is my version from my toolbox.
Code: QB64: [Select]
  1. 'notes: REDIM the array(0) to be loaded before calling Split '<<<<<<<<<<<<<<<<<<<<<<< IMPORTANT!!!!
  2. SUB Split1000 (mystr AS STRING, delim AS STRING, arr() AS STRING)
  3.     ' bplus modifications of Galleon fix of Bulrush Split reply #13
  4.     ' http://xmaxw.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=1612.0
  5.     ' this sub further developed and tested here: \test\Strings\Split test.bas
  6.     DIM copy AS STRING, p AS LONG, curpos AS LONG, arrpos AS LONG, dpos AS LONG, LD AS INTEGER
  7.  
  8.     copy = mystr 'make copy since we are messing with mystr when the delimiter is a space
  9.  
  10.     'special case if delim is space, probably want to remove all excess space
  11.     IF delim = " " THEN
  12.         copy = RTRIM$(LTRIM$(copy))
  13.         p = INSTR(copy, "  ")
  14.         WHILE p > 0
  15.             copy = MID$(copy, 1, p - 1) + MID$(copy, p + 1)
  16.             p = INSTR(copy, "  ")
  17.         WEND
  18.     END IF
  19.     curpos = 1
  20.     arrpos = 0
  21.     LD = LEN(delim) 'mod
  22.     dpos = INSTR(curpos, copy, delim)
  23.     DO UNTIL dpos = 0
  24.         arr(arrpos) = MID$(copy, curpos, dpos - curpos)
  25.         arrpos = arrpos + 1
  26.         IF arrpos > UBOUND(arr) THEN REDIM _PRESERVE arr(UBOUND(arr) + 1000) AS STRING
  27.         curpos = dpos + LD
  28.         dpos = INSTR(curpos, copy, delim)
  29.     LOOP
  30.     arr(arrpos) = MID$(copy, curpos)
  31.     REDIM _PRESERVE arr(arrpos) AS STRING 'need this line? YES to get the ubound correct
  32.  
  33.  

Function: it takes a string, say a whole file gulped in one go with a binary get, and parses the string into a string array using: the specified string to split, delimiter and array name to load.

My version handles splits delimited by spaces specially by removing extra spaces first. 1000 was added to name when Steve recommended only using REDIM _PRESERVE every 1000 times or so instead of at every split.

What else do you need? I have the code used to test the routine.

I am partial to handling the space delimiter specially because this was originally used for space only delimited parser for interpreters I played with but that can be removed and special filter applied in separate function.
« Last Edit: August 11, 2019, 09:24:06 am by bplus »

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #12 on: August 11, 2019, 10:09:12 am »
Okay, we've heard from both sides on the "mem categories" thing...

I think for now, until the collection proves unruly, that our existing tag system will work. Nay on categories. I'll "tell" the Librarian... :-)
You're not done when it works, you're done when it's right.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #13 on: August 11, 2019, 12:33:06 pm »
bplus-

I The Librarian was looking to add BIN$ found at https://www.qb64.org/forum/index.php?topic=1511.0

Code: QB64: [Select]
  1. PRINT 2 XOR 3 ' 2 is 10 in binary, 3 is 11 in binary where there is a bit in one but not the other for 2 and 3 in one's position
  2. PRINT 2 XOR 4 '= 6?  yes
  3. PRINT 2 XOR 10 ' = 8,  10 XOR 1010 = 1000 = 8
  4. PRINT &B0
  5. PRINT &B1
  6. PRINT &B10
  7. PRINT &B11
  8. PRINT &B100
  9.  
  10. 'does QB64 reverse &B numbers conver HEX$ for base 16, OCT$ for base 8, no base 2?
  11.     INPUT "Enter integer to convert to binary "; test
  12.     PRINT "Dec2Base$(test, 2) = "; Dec2Base$(test, 2), "BIN$(test) = "; BIN$(test)
  13.     PRINT "and  VAL(BIN$(test)) ="; VAL(BIN$(test))
  14.     PRINT
  15. LOOP UNTIL test = 0
  16.  
  17. 'what is limit _integer64 can take
  18. i = 1000000000
  19.     i = i + 1000000000
  20.     PRINT i
  21. LOOP UNTIL i >= i + 1
  22.  
  23. 'maybe _BIN$
  24. FUNCTION Dec2Base$ (nDec AS INTEGER, bs AS INTEGER)
  25.     DIM n AS INTEGER, p AS INTEGER, pow AS INTEGER, d AS INTEGER, b$
  26.     n = nDec 'copy this because or nDec gets changed effecting main code
  27.     WHILE bs ^ p <= n
  28.         p = p + 1
  29.     WEND
  30.     FOR pow = p TO 0 STEP -1
  31.         IF n >= bs ^ pow THEN
  32.             d = INT(n / bs ^ pow)
  33.             IF d < 10 THEN
  34.                 b$ = b$ + _TRIM$(STR$(d))
  35.             ELSE
  36.                 b$ = b$ + CHR$(65 + d - 10)
  37.             END IF
  38.             n = n - d * bs ^ pow
  39.         ELSE
  40.             IF b$ <> "" THEN b$ = b$ + "0"
  41.         END IF
  42.     NEXT
  43.     IF b$ = "" THEN b$ = "0"
  44.     Dec2Base$ = b$
  45.  
  46. FUNCTION BIN$ (integerBase10 AS _INTEGER64)
  47.     DIM i AS _INTEGER64, pow AS INTEGER, b$
  48.     IF integerBase10 = 0 THEN BIN$ = "&B0": EXIT FUNCTION
  49.     i = integerBase10 'copy
  50.     pow = 0
  51.     WHILE i > 0
  52.         IF i AND 2 ^ pow THEN
  53.             b$ = "1" + b$
  54.             i = i - 2 ^ pow
  55.         ELSE
  56.             b$ = "0" + b$
  57.         END IF
  58.         pow = pow + 1
  59.     WEND
  60.     BIN$ = "&B" + b$
  61.  

Just want to make sure that:
(i) This is the proper link
(ii) Code in top post is the code you want to show
(iii) You know entering "0" for input causes the program to loop infinitely

Thanks!

------------------------------------------------------------------------------------------

EDIT:

Regarding Split1000: Yes, we need some dead-simple test code for that, 'specially given the huge warning at the top.
« Last Edit: August 11, 2019, 12:44:10 pm by STxAxTIC »
You're not done when it works, you're done when it's right.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Samples/Toolbox re-awakening. Call for entries.
« Reply #14 on: August 11, 2019, 01:21:04 pm »
Hi STxAxTIC,

Here is just the BIN$ function with just the tester code for it.
(BTW that wasn't an infinite loop that was a test of _INTEGER64, I was testing a number of things with main code.)

Code: QB64: [Select]
  1.  
  2. ' QB64 can reverse &H numbers with HEX$ and &O numbers with OCT$
  3. ' but what about &B numbers?
  4.  
  5. ' Here is BIN$
  6.  
  7.     INPUT "(0 ends test) Enter a positive integer to convert to binary "; test
  8.     PRINT "BIN$(test) = "; BIN$(test)
  9.     PRINT "and  VAL(BIN$(test)) ="; VAL(BIN$(test))
  10.     PRINT
  11. LOOP UNTIL test = 0
  12.  
  13. 'BIN$ creates a string = the base 2 equivalent of the Base 10 positive integer
  14. 'and is prefixed with &B to work with VAL
  15. FUNCTION BIN$ (integerBase10 AS _INTEGER64)
  16.     DIM i AS _INTEGER64, pow AS INTEGER, b$
  17.     IF integerBase10 = 0 THEN BIN$ = "&B0": EXIT FUNCTION
  18.     i = integerBase10 'copy
  19.     pow = 0
  20.     WHILE i > 0
  21.         IF i AND 2 ^ pow THEN
  22.             b$ = "1" + b$
  23.             i = i - 2 ^ pow
  24.         ELSE
  25.             b$ = "0" + b$
  26.         END IF
  27.         pow = pow + 1
  28.     WEND
  29.     BIN$ = "&B" + b$
  30.  

I will get going on split1000 next.