View unanswered posts | View active topics It is currently Sat Sep 26, 2020 8:31 am

Reply to topic  [ 2 posts ] 
Sub versus Void 
Author Message

Joined: Sat Jun 02, 2007 8:54 pm
Posts: 17
Post 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.?


Sat Nov 03, 2007 4:07 pm

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
Display posts from previous:  Sort by  
Reply to topic   [ 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

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.