Format question
Don M
Posts: 1,652
I have a buffer: buffer[17]
In that buffer is the following characters: "-> 646E6C00BC3D"
I want to eliminate the "-> " and print the characters from the buffer to look like this by inserting a ":" every 2 characters: 64:6E:6C:00:BC:3D
So here is my code (that doesn't work right):
How do I get it to print the ":" every 2 characters instead of every character?
Thanks.
Don
In that buffer is the following characters: "-> 646E6C00BC3D"
I want to eliminate the "-> " and print the characters from the buffer to look like this by inserting a ":" every 2 characters: 64:6E:6C:00:BC:3D
So here is my code (that doesn't work right):
repeat i from 3 to 16 term.tx(byte[@buffer][i]) term.tx(":")
How do I get it to print the ":" every 2 characters instead of every character?
Thanks.
Don
Comments
There are several ways to do this, here's one.
Edit: I see Mike G has another way.
Edit again: I hadn't seen post #2. There are sure a lot of ways to Spin a cat.
This is longer, but might be easier to adapt as you can set the offset once, and number of byte pairs minus one at the top of the code.