AlanJ Posted September 20, 2024 Report Posted September 20, 2024 I am attempting to write a function block that will take an input word and convert it into an array of Boolian values to access each bit in the word. Following are details: In/Out Variables: Name:InputWord, In/Out: Input, Data Type: Word Name:OutputBits, In/Out: In/Out, Data Type: ARRAY[0..15] OF BOOL Internal Variables: Name: I, Data Type: Int FOR i := 0 TO 15 DO OutputBits := (InputWord AND (1 SHL i)) <> 0; END_FOR; I get a “)” is missing error. What am I doing wrong and how can I fix it?
photovoltaic Posted September 20, 2024 Report Posted September 20, 2024 (edited) SHL needs opening and closing brackets immediately after it. If I may suggest a much easier way to do this - make a union to break a WORD into a BOOL[16] and then simply write the WORD value to the Union.WORD. Alternatively you can assign the same address to the WORD as the BOOL array has and the bits will reflect the WORD. Edited September 20, 2024 by photovoltaic 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now