Functions with arguments

Post your requests and ideas on the future development of mikroBasic PRO for PIC.
Post Reply
Author
Message
MikeRoElectronika
Posts: 25
Joined: 22 Apr 2010 15:08

Functions with arguments

#1 Post by MikeRoElectronika » 15 May 2010 01:43

I would certainly like to see the ability to pass arguments to functions in PBP. The typical method for doing that uses the stack but PICs are somewhat limited in that regard. There are other ways to pass arguments and it would be most helpful if this was implemented.

I also posted a message just prior to this about string types and functions. The omission of those and not being able to pass parameters are not overwhelming problems. The real problem is that anyone with experience using any other BASIC or C compiler will, as I did, just come to a screeching halt when needing a string or trying to create a function. Instead of being able to think about the action or problem you are trying to implement or resolve, you are suddenly trying to figure out how to implement alternatives to almost universal features that are missing. Basic is supposed to make things easy. Adding these features would go a long way toward doing that.

rmteo
Posts: 1330
Joined: 19 Oct 2006 17:46
Location: Colorado, USA

Re: Functions with arguments

#2 Post by rmteo » 15 May 2010 01:52

MikeRoElectronika wrote:I would certainly like to see the ability to pass arguments to functions in PBP.
So would a lot of others http://www.picbasic.co.uk/forum/showthread.php?t=12107 :lol: :lol: :lol:
Functions
Function is declared like this:

sub function function_name(parameter_list) as return_type
[ local declarations ]
function body
end subfunction_name represents a function’s name and can be any valid identifier. return_type is a type of return value and can be any simple type. Within parentheses, parameter_list is a formal parameter list similar to variable declaration. In mikroBasic PRO for PIC, parameters are always passed to a function by value. To pass an argument by address, add the keyword byref ahead of identifier.

Local declarations are optional declarations of variables and/or constants, local for the given function. Function body is a sequence of statements to be executed upon calling the function.
Why pay for overpriced toys when you can have
professional grade tools for FREE!!! :D :D :D

Post Reply

Return to “mikroBasic PRO for PIC Wish List”