TrevorBradley
Active Member
- Joined
- Nov 6, 2007
- Messages
- 732
OK, slightly different problem. This time I'm trying to get functions to return user-defined types. I'm presuming if one function is going to call another, structs won't work.
I can't get this code to compile:
CODE
Program example;
Type _mytype
String value;
End;
Function _mytype hello_world()
Private
_mytype mystring;
Begin
mystring.value = "Hello World";
return mystring;
End
Private
_mytype mystring2;
Begin
mystring2 = hello_world();
write(0,0,0,0,mystring.value);
Repeat
frame;
Until(key(_ESC))
End
Fenix gives me a compiler error: Struct Required ")" on the "mystring2 = hello_world();" line. However "hello_world()" by itself doesn't generate a compiler error.
A second question: How do you get a function to return an array? How do you assign the value of that array when you call the function? I tried pointers, but couldn't get them to work. (I still need an answer to the struct question above though...)
Any ideas? Thanks in advance!
I can't get this code to compile:
CODE
Program example;
Type _mytype
String value;
End;
Function _mytype hello_world()
Private
_mytype mystring;
Begin
mystring.value = "Hello World";
return mystring;
End
Private
_mytype mystring2;
Begin
mystring2 = hello_world();
write(0,0,0,0,mystring.value);
Repeat
frame;
Until(key(_ESC))
End
Fenix gives me a compiler error: Struct Required ")" on the "mystring2 = hello_world();" line. However "hello_world()" by itself doesn't generate a compiler error.
A second question: How do you get a function to return an array? How do you assign the value of that array when you call the function? I tried pointers, but couldn't get them to work. (I still need an answer to the struct question above though...)
Any ideas? Thanks in advance!