Bool Array of "Bits[320]" or a DINT Array of "Bits[10]" ?

skyfox

Lifetime Supporting Member
Join Date
Nov 2006
Location
CA
Posts
279
Logix Platform -

I am looking thru some code and noticed the Original programmer had configured a Boolean array with 320 elements.

Isn't this a waste of controller memory? (doesnt it only use 1 bit and the rest are reserved (not available for use)?

Couldnt he have used an DINT array (DINT[10]) and saved all that memory?

Just wondering what is the prefferd and the smart way to do this.

Individual bits are used as conditional controls in the logic.
 
No - the boolean array is packed as you would want into 32 bit words occupying the same memory as the DINT[10] you proposed. A single BOOL variable, on the other hand, would occupy only one bit out of a 32 bit area. One must also be careful when declaring UDT's. It is best to declare all BOOL variables first and together so that they are appropriately packed.
 
Thanks Bernie,

I see what you mean. I was confused. It only wastes 31 bits if you use a Bool tag. But same is not true when using an array of Bools.

Thanks again.
 

Similar Topics

I'm sorry is this is a FAQ but most indirect addressing samples I have found deal with bytes & words. I have come from an SLC500 background and...
Replies
12
Views
13,941
I received the following message via PM, and am posting here publicly to help others. ============================================ I had a...
Replies
10
Views
1,012
I need to move a large Bool array to Word array in Schneider Control Expert. Is there an easier way to do this? For example: Bool[128] array to...
Replies
4
Views
1,336
Hi, I must move an array of 16 Bool to an array of 2 USINT. I able to do this as attach pisture, but it's not cute! How I can do this with "COP"...
Replies
30
Views
12,003
I am trying to make a function that count the number of True BOOL inn a specific Array and return the count to an INT AlarmArrayActiveAlarms. I...
Replies
8
Views
4,414
Back
Top Bottom