Read a byte from a string

Help find a way to read a byte from a string. Must work with “accumulate string” node. The idea is to select the required number of bytes from the array. Thank you in advance!

Use string-to-int node? We would need more details about what exactly you are trying to do to be of much help.

Do you want to convert every 8 characters to an integer?
You just need to be sure accumulate-string-RST finishes before next accumulate-string-PUSH happens. This is not very robust code, though. If a single character gets dropped, all subsequent numbers are going to be wrong.

1 Like

Thank you very much for your reply! During a certain cycle, a string will be constantly accumulated, from which I need to output one character (byte). The number of the symbol to be displayed must be changed. The bottom line is that I need to make a data array in XOD that could be replenished and, if possible, extract element number n from it. As for the string size, it should be as long as possible. What can you advise?

Not code that I’m proud of, but it seems to work. This outputs the value as a BYTE, which displays as ASCII Hex value.

Sample usage:

Node definition:
That’s using input-string, input-number, not-implemented-in-xod, and output-byte

Double-click on the not-implemented-in-xod node, and paste this C++ code:

struct State {


void evaluate(Context ctx) {
    auto str = getValue<input_STR>(ctx);
    auto idx = getValue<input_IDX>(ctx);
    int i = 0;
    for (auto it = str->iterate(); it; ++it) {
        if (i == idx) {

It has been too long since I’ve done much C++ coding. I took my hex-to-number node & modified it for this function. You should be able to just add to pointer (or index into string), but I’m too lazy to lookup how to get either working (a straight addition to pointer didn’t work). This will output 0 if the index is bigger than string; you could change that to 255 (FFh) if you want 00h to be a valid output.

Note that memory on your Arduino is going to limit how long your string can be.

1 Like

Дякую, це якраз те що мені потрібно. Ви знову допомогли!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.