Hi all!
I am trying to set up some bits as flags (in "C" ), such as:
In the supplementary code window.
bit myflag;
but boostc does not seem to recognise "bit" i.e. it does not highlight in blue.
it states in the boostc manual for example "bit b; //variable will be placed by linker at arbitrary position"
Any help much appreciated!
Dave
declaring a "bit" to use as a flag in flowcode 5
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: declaring a "bit" to use as a flag in flowcode 5
Hi Dave,
You can try the following.
If I were you I would use say a byte variable and use this to pack 8 bool values. Otherwise your bool values will each likely consume a whole byte anyway on their own. They certainly do for GCC based compilers which surprised me.
Setting a bit in the byte.
Clearing a bit in the byte.
Testing a bit in the byte, as 0 or 1.
bitnum = 0-7
This will also simulate correctly in v5 as you can do it all with calculation icons instead of C icons.
You can try the following.
Code: Select all
bool myflag;
Setting a bit in the byte.
Code: Select all
flags = flags | (1 << bitnum)
Code: Select all
flags = flags & ~(1 << bitnum)
Code: Select all
test = (flags & (1 << bitnum)) >> bitnum
This will also simulate correctly in v5 as you can do it all with calculation icons instead of C icons.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: declaring a "bit" to use as a flag in flowcode 5
Thanks for the quick reply Benj!
Thanks for that solution, makes sense!
Just being pedantic here, why is "bit" not recognised by the complier?
Cheers
Dave
Thanks for that solution, makes sense!
Just being pedantic here, why is "bit" not recognised by the complier?
Cheers
Dave
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: declaring a "bit" to use as a flag in flowcode 5
Hi Dave,
probably just goes back to the days pre-GCC where things in C were a bit less well defined.
That's a question for the guys at sourceboostJust being pedantic here, why is "bit" not recognised by the complier?

Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel