I am back again with yet another question, and it seems to me that there is always someone here who knows the answer.
What i am trying to is writing a function for changing the tool on the robot but i am running in to some problems (This is the first time that i use a function).
I start with making a new program and selecting function as template, and after that entering the code that i think i need. this function shall be called from the main program in another src file
GLOBAL DEFFCT INT toolchange(tool_1,tool_2) ;two variables are needed, 1 to select where to place the current tool and the second to select the next tool.
INT tool_1,tool_2
IF (tool_1 == 1) THEN ;repeat this for the necessary number of tools( in my case this will be 5)
;move to position 1 and drop the tool there
ENDIF
IF(tool_2 == 1)THEN ;
;move to position 1 and pick up the tool there
ENDIF
RETURN(); nothing is returned
ENDFCT
Display More
Now for the problems:
1. When i enter the first line to define the function it disappears when i hit enter
2. When the line does not disappear i will get an error from the compiler stating that it is double declared.
3. The compiler also gives an error on ENDFCT stating that this command is not allowed, but when i remove it i get an error that the function is not properly closed.
i have used subprograms before without any problems by just calling the name of the program "subprogram()" an the subprogam could be in the same src file or in another and it would work. On the other hand when i try to call a function like this "function(1,2)" i get an error that the function is not defined. so i added EXTFCT before the call but then the compiler gives the error declaration in the wrong place.
I am working with a KRC2 with Ks 4.9. I have no idea what i am doing at the moment so any help is appreciated.