function argument is not a is not a constant expression

This must be a pretty trivial error, can I pass arguments as constant?
Or do I even have to? radius should be a copy here ?

PROC get_pitch(num turnSpacing, num radius, INOUT num slope_angle)
CONST num circum := l_PI * 2. * radius;
ENDPROC

gets me

System1/RAPID/T_ROB1/Module1(317,41): Data declaration error(20): Expression radius is not a constant expression. 5/08/2019 3:57:31 PM General

Also getting similar result with FUNC.
num radius is not a copy?

it works with everything in 1 line but that’s silly
PROC get_pitch(num turnSpacing, num radius, INOUT num slope_angle)
slope_angle := toDegree(ATan(turnSpacing / l_PI * 2. * radius));
ENDPROC

It needs a constant, because you declare and initialize the value at the same line.

CONST num circum := l_PI * 2. * radius;
  ^    ^
  |    |

You can fix this by doing this for example:

PROC get_pitch(num turnSpacing, num radius, INOUT num slope_angle)
        VAR num circum := l_PI;
        circum := l_PI * 2. * radius;
ENDPROC

or


VAR num circum;
PROC get_pitch(num turnSpacing, num radius, INOUT num slope_angle)
        circum := l_PI * 2. * radius;
ENDPROC

let me try, i think CONST didnt do it.
Ah, right i need to declare separately. First time i meet a language with that requirement but thanks for your help

Hi Eric, Thanks for your answer, which also solved my problem.

I am wondering, why seperate the declaration and assignment expression could solve the problem. Is there anything to do the way Robotstudo allocates it’s memory?

Appreciated!