Declaring Functions AS TYPEs
#9
(08-16-2023, 11:53 AM)OldMoses Wrote: I feel your pain. Working with vector types just screams having a way to directly functionalize their manipulation. I resort to the somewhat clumsy approach of passing a variable back from a sub. The main issue being keeping track of which variable is the desired result. I use the first parameter as a return. Then I have to decide if I want to preserve original operands or overwrite them. At least it can be done in a fairly concise manner.

I imagine that since there are no rules against multi-dimensional (4+ element) vectors, there is simply no point in trying to satisfy all possibilities. So we'll just have to do the typical hacks.
Yep, I do the same sort of thing. It would be much nicer using a function instead of a subroutine though.,

Code: (Select All)
SUB AddVector (vin AS TYPE_VECTOR, vout AS TYPE_VECTOR)

    '| Add vin to vout. vout will contain the passed back result.
    '|
    '| AddVector MouseVector, WindowLocation

    vout.x = vout.x + vin.x
    vout.y = vout.y + vin.y

END SUB
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply


Messages In This Thread
Declaring Functions AS TYPEs - by TerryRitchie - 08-16-2023, 02:26 AM
RE: Declaring Functions AS TYPEs - by dbox - 08-16-2023, 02:56 AM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 03:08 AM
RE: Declaring Functions AS TYPEs - by OldMoses - 08-16-2023, 11:53 AM
RE: Declaring Functions AS TYPEs - by TerryRitchie - 08-16-2023, 02:52 PM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 12:33 PM
RE: Declaring Functions AS TYPEs - by a740g - 08-16-2023, 12:38 PM
RE: Declaring Functions AS TYPEs - by bplus - 08-16-2023, 02:38 PM
RE: Declaring Functions AS TYPEs - by Kernelpanic - 08-16-2023, 04:14 PM
RE: Declaring Functions AS TYPEs - by grymmjack - 08-16-2023, 09:50 PM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 11:25 PM
RE: Declaring Functions AS TYPEs - by bplus - 08-17-2023, 12:41 AM



Users browsing this thread: 4 Guest(s)