Sign in to follow this  
Followers 0
Difool

Accessing bit of word

2 posts in this topic

Hi guys, I have to extract a decimal value from a string (bar code) I also want to access to bits of this extracted value. String example : *ZZ00116384* Value to extract : 16384 (= 0100000000000000) For now i have the following code : TestCode := STRING_TO_WORD(MID(Reference, LEN(Reference) - 16#7, 16#7)); TankVersion := TestCode[15]; Reference is STRING(12) TestCode is WORD TankVersion is BOOL But when I compile, I have the following error : "incorrect index array" How I can do that ? Thanks ! Edited by Difool

Share this post


Link to post
Share on other sites
Finally, I've found a solution to do what a want : TestCode (WORD) Reference (STRING) TankVersion (BOOL) TestCode := UINT_TO_WORD(STRING_TO_UINT(MID(Reference, LEN(Reference) - 16#7, 16#7))); IF SHR(TestCode & 2#0100000000000000, 14) = 1 THEN TankVersion := TRUE; ELSE TankVersion:= FALSE; END_IF; Edited by Difool

Share this post


Link to post
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
Sign in to follow this  
Followers 0