I was wondering if I can pass an array to a function.
And the function must return an array.
For example I want to make a outproduct or dotproduct function
So
procedure outproduct(vecta(3),vectb(3))
code
return vect(c)
endprocedure
This doesn't work of course, but how can I do this easily?
Passing an array to a function
Structure whatever
b.b
EndStructure
Procedure aha(*a.whatever, *b.whatever)
*b\b = *a\b
EndProcedure
x.whatever
y.whatever
x\b = 5
aha(@x,@y)
Debug y\b
b.b
EndStructure
Procedure aha(*a.whatever, *b.whatever)
*b\b = *a\b
EndProcedure
x.whatever
y.whatever
x\b = 5
aha(@x,@y)
Debug y\b
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Passing an array to a function
I'd do it with structures...peter wrote: procedure outproduct(vecta(3),vectb(3))
code
return vect(c)
endprocedure
Code: Select all
Structure VECT
x.f
y.f
z.f
EndStructure
Procedure outproduct(*va.VECT, *vb.VECT, *out.VECT)
code
EndProcedure
viewtopic.php?t=9457
Good programmers don't comment their code. It was hard to write, should be hard to read.
Re: Passing an array to a function
ooops, too late... 
Good programmers don't comment their code. It was hard to write, should be hard to read.

