Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
New to QB64pe? Visit the QB64 tutorial to get started.
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Arrays inside Types? Ikerkaz 20 486 8 hours ago
Last Post: Jack
  Methods in types bobalooie 7 1,575 01-30-2025, 08:00 PM
Last Post: Pete
  C++ types > QB64 types: do we have an equivalent QB64PE page? madscijr 5 1,131 06-01-2024, 03:44 AM
Last Post: grymmjack
  Date functions dritter 31 5,008 05-20-2024, 04:22 PM
Last Post: dano
  need help converting old style def fn functions madscijr 11 2,894 07-27-2022, 02:07 AM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)