![]() |
Forum Index : Microcontroller and PC projects : Array Element as Subroutine Argument
Author | Message | ||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
I take it that the arguments in the declaration of a subroutine cannot be array elements. Too bad. ![]() x = 1 y = 1 UnitNormal x,y print x,y end sub UnitNormal u(0),u(1) ' <==== NOT ALLOWED! DRAT. MATH V_NORMALISE u(),u() end sub Instead, the subroutine must be sub UnitNormal n1,n2 u(0) = n1 : u(1) = n2 MATH V_NORMALISE u(),u() n1 = u(0) : n2 = u(1) end sub Is there a simpler way? Visit Vegipete's *Mite Library for cool programs. |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
Can't you use this? u(0) = 1 u(1) = 1 UnitNormal u() print u(0), u(1) end sub UnitNormal a() MATH V_NORMALISE a(), a() end sub Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
Not really, because the actual 'vector' I want to normalize is deep in a multi-dimensional array. A bunch of MATH SLICE and MATH INSERT gets too complicated. The input would be something like UnitNormal a(i,3),a(i,4) Visit Vegipete's *Mite Library for cool programs. |
||||
LeoNicolas![]() Guru ![]() Joined: 07/10/2020 Location: CanadaPosts: 504 |
Can you add the array values to variables before assign them to the sub? dim v1=a(i,3),v2=a(i,4) UnitNormal v1,v2 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |