I have this function (converting coordinate of an WGS84 geoid to cartesian coordinates...doesn't matter):
function convert_geo_to_enu(coord_geo) { \
xi=sqrt(1 - e*e*sin(coord_geo[1])*sin(coord_geo[2])); \
\
coord_enu[1]=(a/xi + coord_geo[3])*cos(coord_geo[1])*cos(coord_geo[2]); \
print coord_enu[1] " hhh " ; \
coord_enu[2]=(a/xi + coord_geo[3])*cos(coord_geo[1])*sin(coord_geo[2]); \
coord_enu[3]=(a*(1-e*e)/xi0 + coord_geo[3])*sin(coord_geo[1]); \
\
return coord_enu \ # <-- here comes the problem
} \
problem --> mawk: line 64: illegal reference to array coord_enu
What is the problem to return as an array? Is there any different syntax?
I could use:
function convert_geo_to_enu(coord_geo, coord_enu) { \
...
coord_enu[1]=...
...
} \
or even:
function convert_geo_to_enu(coord_geo) { \
...
coord_enu[1]=...
...
} \
and then just use the variable coord_enu
as a global?
But it looks better with usage of return statement (esp. for me)
A little late, but here's a solution I used:
I sent a variable I wanted filled as a parameter to the function:
function myfunct(result, array_size) {
for(i = 1; i <= array_size; i++) {
result[i] = ##whatever you want
}
}
then, you can treat the result variable as an array outside of the function
hope this helps someone looking for an answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With