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 support@ccsinfo.com

Help Deciding on Data Type

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Help Deciding on Data Type
PostPosted: Wed Oct 12, 2005 8:58 pm     Reply with quote

Hello All,

I'm trying to figure out how to deal with the following data issues...

I'll have about 150 "items" predefined and each will have the following attributes:

Code:

unit_number   int16   //condo unit number
cable_number  int8    //ribbon cable LEDs are on
group_number  int8    //group of 8 on the cable
bit_mask      int8    //bits that make-up the units LEDs


I need to be able to do the following things with the items and attributes:

Search by unit number
Access the bitmask value to generate a WRITE_SPI
Preload or predefine all the values for each item & attribute


I was going to make a structure, but how would you predefine all the values prior to compilation?

I was thinking of an array of int8s, but the unit number's requirement to be an int16 threw me....

Could the experts help me?

Thanks,

John
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Wed Oct 12, 2005 10:35 pm     Reply with quote

OK, tell me if this is a really awkward way of handling the issue at hand.

I will create and populate an int16 array of the unit numbers.

I will create and populate a 2 dimensional int8 array of the other data that goes along with the unit number. (I will ensure that the data for each unit has the same index as its associated unit.)

When I need the data for a unit I will search the unit array to deduce the index for that unit. I'll then use that index to access the other array to extract the data....

Creative problem solving? or hideous abortion of coding?

Thanks,

John
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