Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interweaving SUB and FUNCTION
#10
(02-02-2026, 08:46 AM)luke Wrote: Didn't codeguy have a SUB & FUNCTION sorter program? I'm sure that could be easily adapted to ensure all the subprocedures are before / after the main procedure.

Too long ago for my 4K memory to access. All I remember about codeguy is Clippy threw a coffee pot at him once, and I remember that story because it would have been funnier if he threw a toaster.

I would think the QB64 IDE would contain this function, because it does sort out subs and functions in the F2 View tab.

To make one from scratch, hmm... Identifying subs, piece of cake. Identifying functions, piece of my sister-in-laws cake... rock hard fresh out of the oven. I suppose it would take eliminating all underscore keywords, by eliminating any string that started, or string segment after a colon, with an underscore. Then each QB45 keyword a string started with would have to be eliminated, including metacommands, etc. Oh, get rid of labels and line numbers, too! What's left would be the name of a function. Now add to that the function could end with an "End Sub" instead of an "End Function", and those could either be the start of a string or placed in a string after a colon.

I wonder if there is a keyword hash table in this project?  I'd jut go with step one in a hash table creation, make a comma delimited QB45 keyword list and use INSTR(). If the string segment returned an INSTR() value of zero, it's a sub or a function. Of course now that these can occur anywhere in the code, i it a call to a sub or function, or the sub or function, itself? Now method would need to check for parentheses or the optional use of "Call" to identify the differences.

Now if you will excuse me, I'm working on a program for Steve. Last week he dropped a needle in his haystack...

Pete
Reply


Messages In This Thread
Interweaving SUB and FUNCTION - by SMcNeill - 01-29-2026, 02:31 PM
RE: Interweaving SUB and FUNCTION - by SMcNeill - 01-29-2026, 02:41 PM
RE: Interweaving SUB and FUNCTION - by Pete - 01-29-2026, 07:12 PM
RE: Interweaving SUB and FUNCTION - by ahenry3068 - 01-30-2026, 02:25 PM
RE: Interweaving SUB and FUNCTION - by SMcNeill - 01-30-2026, 03:25 PM
RE: Interweaving SUB and FUNCTION - by Pete - 02-01-2026, 09:03 PM
RE: Interweaving SUB and FUNCTION - by grymmjack - 01-31-2026, 04:11 PM
RE: Interweaving SUB and FUNCTION - by mdijkens - 02-01-2026, 08:23 PM
RE: Interweaving SUB and FUNCTION - by luke - 02-02-2026, 08:46 AM
RE: Interweaving SUB and FUNCTION - by Pete - 02-02-2026, 04:20 PM
RE: Interweaving SUB and FUNCTION - by SMcNeill - 02-02-2026, 04:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fast replace$() function mdijkens 10 1,888 04-19-2025, 06:27 PM
Last Post: mdijkens

Forum Jump:


Users browsing this thread: 1 Guest(s)