DIMPUSH w$[], MyFunc(t$[1])
"0" is always pushed onto w$[]. It makes nor difference if MyFunc() has a ByRef or pass by value, the return value is ignored by DIMPUSH.
It works ok if the function is named MyFunc$ so that it can return a string. Set Debug mode, and check the output.
Here's my test
GLOBAL w$[]
GLOBAL t$[]
LOCAL m$
DIMPUSH t$[], "123"
DIMPUSH t$[], "456"
DIMPUSH t$[], "789"
m$ = MyFunc$("abc")
DEBUG m$ + "\n" //<-- outputs "helloabc"
DIMPUSH w$[], MyFunc$(t$[1])
DEBUG w$[0] + "\n" //<-- outputs "hello456"
FUNCTION MyFunc$: tt$
LOCAL x$ = "hello"
x$ = x$ + tt$
RETURN x$
ENDFUNCTION
Edit: I always make my empty arrays global so I can use then inside functions. Not in this case, but it's a habit.
Thanks for testing this.
Yes your code works fine.
Unfortunately mine doesn't and I'm not sure why. The function mentioned is part of an extended type, I'll need to experiment more and find out why it's still doing this and if it has something to do with being within and extended type.
Thanks for looking though.
The function works ok inside a TYPE. Unless I am misunderstanding your problem
TYPE TESTType
t$[]
w$[]
FUNCTION Test1:
DIM self.t$[0]
DIM self.w$[0]
DIMPUSH self.t$[], "123"
DIMPUSH self.t$[], "456"
DIMPUSH self.t$[], "789"
DIMPUSH self.w$[], self.MyFunc$(self.t$[1])
DEBUG self.w$[0] + "\n"
ENDFUNCTION
FUNCTION MyFunc$: tt$
LOCAL x$ = "hello"
x$ = x$ + tt$
RETURN x$
ENDFUNCTION
ENDTYPE
LOCAL test AS TESTType
test.Test1()
Thanks again. ;)
I am looking at my code listing and I think that I have omitted a single "self." but the compiler has not reported this and went ahead with the function call. It should not have allowed this though as I have "Explicit Declarations" in the project settings. I can't do a compile till tomorrow, I'll look into this a little further then.