 |
ALPHA-VISION® Functions: aci.Obj_SetFlag
|
aci.Obj_SetFlag
SUMMARY
Set single bits in the value or status of a data object.
SYNTAX
aci.Obj_SetFlag(
(<object number>|<point id>),
<attr>,
<bitmask>,
<flag>)
ARGUMENTS
- object number (type:number)
-
A data object number
- point id (type:string)
-
The name of a data object
- attr (type:integer)
-
An identifier for the required attribute.
Use the global table DOATTR.
The names elements of DOATTR have the same names as the attributes in the display editor.
For a list of attributes see aci.Obj_QueryAttr.
- bitmask (type:integer)
-
Specifies the bits that shall be affected.
- flag (type:integer)
-
Specifies the bits that shall be set to 1.
ERROR HANDLING
The function will fail and terminate script execution if strict error checking is enabled (see
aci.SetStrictMode()) and
one of the following conditions is met:
-
The given data object does not exist.
-
The value of the attribute cannot be set.
The normal reason for this is that the data object does not have such an attribute.
If this occurs and strict checking is disabled the function returns
nil.
EXAMPLES
- Bits 0 and 1 are left-shifted until bit 0 arrives at the lowest bit in the mask.
Then the flag-bits defined by the mask (1 and 3) are adapted.
- Bit 1 = 1, bit 3 = 0.
- Any other bits remain unchanged.
aci.Obj_SetSts("TEST_1", 0xf0)
aci.Wait(1000)
aci.Obj_SetFlag("TEST_1", DOATTR.Status, 0x0a, 0x03)
aci.Wait(1000)
assert(aci.Obj_Sts("TEST_1") == 0xf2)
-- 0xf0 = 11110000 original status
-- 0x0a = 00001010 bitmask
-- 0x03 = 00000011 flags
-- 00000110 after shifting
-- 0xf2 = 11110010 result
Syntax Notation
- [aaa]
- aaa is optional (zero or one occurences)
- (aaa|bbb)
- aaa exclusive or bbb
- (aaa)*
- aaa may occur indefinitely often or may be omitted
- (aaa)+
- aaa may occur indefinitely often but at least once
- (aaa)m..n
- aaa may occur from m to n times