How to make a custom function in my rapid program?
Best Answer
-
Here is an simple example.
FUNC num abs_value(num value)
IF value<0 THEN
RETURN -value;
ELSE
RETURN value;
ENDIF
ENDFUNC
gr,
5
Answers
-
Here is an example of a simple function. FUNC num abs_value(num value) IF value<0 THEN RETURN -value; ELSE RETURN value; ENDIF ENDFUNC gr, Richard0
-
Thanks, I didn't declare the function type0
-
Hi, Just wondering how can you make the custom functions global? Do you need to declare in a header file or something and include the header file in your main?RegardsKent0
-
Hi,
all procedures, functions and data declarations are defined as global in a Task if the argument "LOCAL" is not used.
Examples for global declarations:
CONST num nMyNum:=1;
PROC MyProc()
FUNC num MyFunc()
Examples for local declarations in a module:
LOCAL CONST num nMyNum:=1;
LOCAL PROC MyProc()
LOCAL FUNC num MyFunc()
If you are using a persistant data declaration, you have the following possibilties
PERS num nMyNum:=0; (Persistant is defined as global for all tasks, in case of same declaration is available in the other tasks
LOCAL PERS num nMyNum:=0; (Persistant is only available in the module)
TASK PERS num nMyNum:=0; (Persistant is global in the current task)
Regards
Micky
1
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 783 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings