Search the Community

Showing results for tags 'bitwise operations'.

• Search By Tags

Type tags separated by commas.

Forums

• General
• Announcements and Site News
• AutoIt v3
• AutoIt Help and Support
• AutoIt Technical Discussion
• AutoIt Example Scripts
• Scripting and Development
• Developer General Discussion
• Language Specific Discussion
• Operating System Deployment
• Windows Client
• Windows Server
• Office

Categories

• AutoIt Team
• Beta
• MVP
• AutoIt
• Automation
• Databases and web connections
• Data compression
• Encryption and hash
• Games
• Hardware
• Information gathering
• Internet protocol suite
• Maths
• Media
• PDF
• Security
• Social Media and other Website API
• Windows
• Scripting and Development
• Operating System Deployment
• Windows Client
• Windows Server
• Office

• Forum FAQ
• AutoIt

Calendars

• Community Calendar

Found 1 result

1. A little elegance required

Hi there I know how to solve this problem with brute force, but I like my code to have some elegance so thought I would seek some help. I am not very familiar with bitwise operations so am floundering a little. A small part of my programme has four checkboxes, labelled \$cbImp[1-4]. Rather than store a binary on/off field four times I have used a bitwise operator to store all possible combinations (15) as a number, thusly: for \$item = 1 to 4 if GUICtrlRead(\$cbImp[\$item]) = \$GUI_CHECKED then \$temp[\$item]=2^(\$item-1) Next \$Impacts=BitOR(\$temp[1],\$temp[2],\$temp[3],\$temp[4]) This works well and stores in the database in a single field a number which I can (in my head) read back and restore the checkboxes to their previous state. However, I can't find an elegant way to handle the 15 combinations (each checkbox being checked or unchecked) [actually it might be 16 - doesn't matter] with a huge case statement or some such. I know if I read in an odd number it will always mean that \$cbImp[1] will be checked. I know a number greater than 8 will mean that \$cbImp[4] will be checked, but the middle two numbers look difficult. Any pointers? (I hope I explained this well enough)
×
×
• Create New...