Ahmed Ibrahim Osman Posted November 21, 2017 Report Posted November 21, 2017 convert string to byte array in Unity pro
cHud Posted November 21, 2017 Report Posted November 21, 2017 you dont convert string to byte Byte is a size in length of bits. The byte can be on type string or int or whatever. Please use a translator and ask a full question. We cannot help on the above post....or lack there of
Ahmed Ibrahim Osman Posted November 21, 2017 Author Report Posted November 21, 2017 I am sorry sir but i try to say That i have tag data type is String consist of 22 characters, i want to extract character and convert to Byte or to do some calculation. Is there any function block can i use it ? Thanks
cHud Posted November 22, 2017 Report Posted November 22, 2017 2 hours ago, Quant said: I hope it will help you: Nice example hahaha
Ahmed Ibrahim Osman Posted November 23, 2017 Author Report Posted November 23, 2017 I have tag data type is String consist of 22 characters, i want to extract one character and convert into Int to do some calculations, i have used( MID_INT) Function Block extracts a sub-string of characters starting from a certain rank. The result is a character string but I want to put in Array of strings or Array of Bytes and then take every Byte or character to do some calculations.Summarization: how I can extract one character from string[n] composed of set of characters (n) is number of characters TO DO SOME CALCULATIONS LOOK Is There any function Block can i use it? Thanks Quant cHud
Quant Posted November 23, 2017 Report Posted November 23, 2017 I'm not sure if it something complex or is it to easy :( Your calculation looks like this:
Ahmed Ibrahim Osman Posted November 23, 2017 Author Report Posted November 23, 2017 Excuse me, I don't understand anything please i want more explain and details Quant
Quant Posted November 23, 2017 Report Posted November 23, 2017 I used standard blocks in my example and call all variables with their names. 1) ok, first set values to zero count:=0; DO_SOME_CALCULATION := 0; 2) do a loop for number of elements/characters in your STRING. In your case you have every time 22 characters, so you can just use LEN_ORIGINAL_STRING:=22. 3) you separate every character from STRING - I call it ELEMENT_OF_STRING as INT 4) you split INT in to 2 Bytes: ELEMENT_BYTE1 and ELEMENT_BYTE2 5) you calculate something that you need with both bytes - I call it DO_SOME_CALCULATION 6) finish :) 1
Ahmed Ibrahim Osman Posted November 23, 2017 Author Report Posted November 23, 2017 Thank you very much Mr Quant i will do it Quant
Ahmed Ibrahim Osman Posted November 23, 2017 Author Report Posted November 23, 2017 MR.QUANT i have some problems with write code it's showed me that and i don't understand what is function( INT_AS_BYTE) Quant
Quant Posted November 24, 2017 Report Posted November 24, 2017 you are missing INT_AS_BYTE block. But it was only example from me, it was not exactly 100% what you need.
ABlearner Posted November 24, 2017 Report Posted November 24, 2017 Hi there! I have a question with AB PLC. My problem: I have some raw data...distance for example.When the machine starts,the sensor begins to send the information with the distance values. When data is received it is moved into an array. After the first 5 values the program calculates an average and the result is moved into another array.Currently after receiving the fifth value,thus filling the first array,making the calculation and sending the average to the other array,the program empties the entire first array instead of just always discarding the oldest value of the five,and recalculating the average with the newly arrived value every time. I tried to made this with ladder diagram using an an fifo load and unload but isnt working. Please help me if anybody can. Thank You.
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