CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

#define

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
girlinpink
Guest







#define
PostPosted: Sun Jun 15, 2008 9:39 am     Reply with quote

#define modo datain[0]
#define param1 datain[1]
#define param2 datain[2]
#define resultado dataout[0]

hello everybody. i'm pretty new to ccs and the code above is part of my usb coding. here's my question, what does the [1] or [2] mean?

thanks in advance!
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Sun Jun 15, 2008 10:06 am     Reply with quote

"datain" is an array. datain[0] is the first element of the array, datain[1] the second element, and datain[2] the third.
_________________
David
girlinpink
Guest







PostPosted: Sun Jun 15, 2008 10:17 am     Reply with quote

#define mode datain[0]
#define data datain[1]
#define param1 datain[1]
#define param2 datain[2]
#define modeo dataout[0]
#define sdcard dataout[1]
#define conv dataout[1]
#define result dataout[1]
#define swst dataout[1]

this is another example which i grabbed from the internet. part of the usb coding also. as u can see, there's two datain[1]. i'm still very confused.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Mon Jun 16, 2008 2:44 am     Reply with quote

Basically the person who wrote the code created the #defines to make programming easier.
A #define value will be replaced by the definition during compile.

From what I can see I assume the code where the defines are used have 2 arrays available, datain[] and dataout[].

The data in the datain array is organised so that the value at index 0 [0] is the mode and from [1] onwards is the data. Also the data at [1] and [2] are known as param1 and param2.
It is similar to dataout where the value at index 1 [1] can be either sdcard, conv, result or swst depending on the modeo vaule.

So as you see it is just there way of making it easier to read the code.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group