function argument is not a is not a constant expression
kschmid
✭
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 ?
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
Post edited by kschmid on
0
Comments

It needs a constant, because you declare and initialize the value at the same line.
</code>CONST num circum := l_PI * 2. * radius;<br> ^ ^<br>  <br></pre><br></div><div>You can fix this by doing this for example:</div><div><br></div><div><pre class="CodeBlock"><code>PROC get_pitch(num turnSpacing, num radius, INOUT num slope_angle)<br> VAR num circum := l_PI;<br> circum := l_PI * 2. * radius;<br>ENDPROC
or<code>VAR num circum;<br>
PROC get_pitch(num turnSpacing, num radius, INOUT num slope_angle)
circum := l_PI * 2. * radius;
ENDPROC
2 
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 help0

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!0
Categories
 10.4K All Categories
 5.3K RobotStudio
 351 UpFeed
 15 Tutorials
 9 RobotApps
 282 PowerPacs
 404 RobotStudio S4
 1.8K Developer Tools
 239 ScreenMaker
 2.6K Robot Controller
 251 IRC5
 36 OmniCore
 6 RCS (Realistic Controller Simulation)
 3 RobotStudio AR Viewer
 702 RAPID Programming
 14 Wizard Easy Programming
 107 Collaborative Robots
 3 Job listings