|
Page 1 of 1
|
[ 2 posts ] |
|
Author |
Message |
Dave Crabbe
Rookie
Joined: Sat Jun 02, 2007 8:54 pm Posts: 17
|
 Sub versus Void
I have limited experience with C but I'm trying to debug a problem with a motor encoder subroutine that works fine when I execute it by itself, but is not working within a larger program... my questions is in the use of SUB versus VOID for creating a subroutine.. and if I'm using this incorrectly (I have been using the SUB statement)
sub subname()
{
// sub statements (return statement not required)
}
void subname()
{
// statements
}
Do both of the above do the same thing?.. in particular I'm wondering if both are true subroutines or if the VOID simply copies the code 'in-line' each time the void reference appears in the main program. Can I use the 'sub' keyword to create a subroutine, or is this non-standard use of the sub keyword (in C tutorials I see on-line none use the sub keyword, so maybe I am using this incorrectly)
Should both be able to work fine for subroutine use.?
dave
|
Sat Nov 03, 2007 4:07 pm |
|
 |
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 616
|
No. You should not use "sub" statement.
I'm suprised that you were able to find it. It's an undocumented legacy from a very early version of ROBOTC. I've just added a warning message to the compiler when it is used. IT should behave exactly as a "void" function.
The preferred (and 'C' compliant) method is to use a function definition with return type "void".
|
Thu Nov 15, 2007 11:00 am |
|
|
|
Page 1 of 1
|
[ 2 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|