Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
an "overloaded subroutine" example
#5
My new way of doing something similar to this is to break down what I need into sub-functions with a .DESCRIPTOR to them.

Such as I write a long arse routine for an expansive box routine.

SUB Box (x, y, wide, tall, caption$, xOffset, yOffset,Kolor, BGkolor... a zillion more parameters.)

Now that's a LOT to keep up with and deal with and many of those params I won't ever need, so I write a dozen sub-subs to call that sub for me.

SUB Box.AutoSize (x, y, caption$)
'this now calculates the width and height of the caption, the width/height of my border needed.  It sets color and background color to the default values.  And then it does:
    BOX (x, y, wide, tall, caption$, XOffset... a zillion more parameters with what it filled in for me.
END SUB

I'll have a half dozen or more BOX commands, but almost like OOP, I design them with .DESCRIPTORS so I only have to pass the parameters to them that I want.  It's not *true* overloading as Rho mentions, as that would generate errors, but it's about as close as we're going to get with optional parameters anytime soon.  Just make the main routine with the bazillion options first and then the sub-wrappers with only the relevant needed parameters with a DOT-NAME.

It's a practice I've started to adopt here lately and it's helping me organize my thoughts and routines quite nicely.  It may be something else which others can learn to adapt to as well, so I just thought I'd share.  Whatever works for you... That's what works.  This is now my way of finding something new that works for me, and so far it's been working really well.  Wink
Reply


Messages In This Thread
RE: an "overloaded subroutine" example - by bplus - 05-08-2025, 07:55 AM
RE: an "overloaded subroutine" example - by bplus - 05-08-2025, 10:20 AM
RE: an "overloaded subroutine" example - by SMcNeill - 05-08-2025, 12:42 PM
RE: an "overloaded subroutine" example - by Jack - 05-08-2025, 03:28 PM



Users browsing this thread: 1 Guest(s)