A compiler error occurs in AppGameKit Studio tier 1 if a function is defined using both a parameter list and a declared return type.
function TestReturnValue(parameter1 as integer) as integer
Print("This is a test function, and it is designed to return the value of 123.")
Sync()
endfunction 123
The compiler will report: 'Error: Unexpected token "as", function declaration must end with a new line'
However, if the same function is defined with a parameter list but without a declared return type, it will compile.
function TestReturnValue(parameter1 as integer)
Print("This is a test function, and it is designed to return the value of 123.")
Sync()
endfunction 123
Similarly, if the same function is defined without any parameter list, but with a declared return type, then it will compile.
function TestReturnValue() as integer
Print("This is a test function, and it is designed to return the value of 123.")
Sync()
endfunction 123
Notice that the function syntax which triggers a compiler error has both a parameter list and a declared return type. To my knowledge, this is (should be) acceptable syntax. I am not sure if this is a bug in the compiler, or if this detection is intentional.
In any case, an effective workaround is to define the function without a declaration of a return type, even if the function does return a value. This is an imperfect solution, but it seems to work effectively.
Does anyone else have any suggestions or recommendations for a better solution than the workaround I listed? Is it incorrect syntax to have a function which has both a parameter list and a declared return type? Thanks in advance for any suggestions or insights.