Functions in Pic Basic Pro
I wanted to know if it is possible to write function in picbasic. By functions i am referring to the functions that you write in higher level languages like C, where you can pass a value to this function, it performs some operations and then returns a value. i have gone through the pic basic pro manual and i havent found anything that will do this. The closest thing is the gosub routine but gosub doesnt return a value, but other than that i havent found anything else. I want to use functions so that i can make the program more efficient and to save space of the program memory space, and also make debugging easier. The PIC i am using is an 18F2550. So if anyone has any suggestions please let me know.
Passing variables to subroutines
Not entirely sure I see your problem. You can easily pass values to a subroutine and the subroutine can return new values for the program to act on.
For example, I can set up an array of characters to send and then call a custom built TRANSMIT subroutine. That subroutine might have error checking and require a handshake or acknowledgement from the distant receiver. The results of that acknowledgement or other parameters like time of transmission, etc are stored in variables that are accessible to the main program once the subroutines finishes.
Likewise I can call a RECEIVE subroutine that gets a group of characters and stores them in an array for the main program to use.
If you need speed, and you can handle assembler, then the subroutine can include blocks of assembly language by using the ASM/ENDASM instructions