Jump to content
The simFlight Network Forums

How Read/Write single Bit 2^ Flag - different in VB8


Recommended Posts

My question is:

How Read + Write a single Flag value with Visual Basic 2008 ?

Example: FSuipc - Offset 3366 - Var.Type U8 - Bit 0 .. 7

If you are using my DLL then the easiest way is to declare the offset as a 'BitArray' type.

The sample application included with the DLL has an example of using a BitArray offset for the lights.

Basically, you need to declare the offset as follows:


Dim enginesOnFire As Offset(Of BitArray) = New FSUIPC.Offset(Of BitArray)(&H3366, 1)
[/CODE]

Note the size is 1 because the offset is 1 byte.

Then after processing you can check if each bit is set by using an array index. This is 0 based so to test is bit 0 is set you use:

[CODE]
If enginesOnFire.Value(0) = True then
' Engine 1 on Fire!
end if
[/CODE]

Engine 2 would be enginesOnFire.Value(1)

Engine 3 would be enginesOnFire.Value(2)

Engine 4 would be enginesOnFire.Value(3)

You can also set and reset these bits by setting the value to True or False repectively e.g.

[CODE]
enginesOnFire.Value(2) = True
[/CODE]

although the documentation says this probably doesn't start a fire in the simulation, just sets the warning light.

Paul

Link to comment
Share on other sites

If you are using my DLL then the easiest way is to declare the offset as a 'BitArray' type.

The sample application included with the DLL has an example of using a BitArray offset for the lights.

Basically, you need to declare the offset as follows:


Dim enginesOnFire As Offset(Of BitArray) = New FSUIPC.Offset(Of BitArray)(&H3366, 1)
[/CODE]

Note the size is 1 because the offset is 1 byte.

Then after processing you can check if each bit is set by using an array index. This is 0 based so to test is bit 0 is set you use:

[CODE]
If enginesOnFire.Value(0) = True then
' Engine 1 on Fire!
end if
[/CODE]

Engine 2 would be enginesOnFire.Value(1)

Engine 3 would be enginesOnFire.Value(2)

Engine 4 would be enginesOnFire.Value(3)

You can also set and reset these bits by setting the value to True or False repectively e.g.

[CODE]
enginesOnFire.Value(2) = True
[/CODE]

although the documentation says this probably doesn't start a fire in the simulation, just sets the warning light.

Paul

Many thanks for you explanation. It's OK.

regards

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.