Другое Covert

Parazitas

Участник
Автор темы
18
7
Hello
Maybe someone can covert this c ++ snippet to cleo snippet?
I'm not good with strings in cleo, so i can't do it myself
Код:
#include <iostream>
#include <string>

void ChangeString (std :: string & test)
{
    bool inbracket = false;
    std :: string outStr;
    for (size_t i = 0; i <test.size (); ++ i)
    { 
        char ch = test [i];
        if (ch == '[') 
           inbracket = true;
        else
        if (ch == ']')
           inbracket = false;
        else
        if (! inbracket)
           outStr + = ch;
     }
     test = outStr;
}

using namespace std;

int main () 
{
    std :: string test = "[12] 1234 [56] 78";
    ChangeString (test);
    cout << test;
}
 
Последнее редактирование:

hnnssy

Известный
Друг
2,684
2,744
писал на коленке, протестить негде
если чё допилишь
и ваще клео - говно
CLEO:
{$CLEO}
{$NOSOURCE}
0000:
wait 2000

31@ = 0
reg_cmd "tstr" @wc

while true
wait 0
if 31@ == 1
then
    call @changeString 1 0@
    31@ = 0
end
end

:wc
cmd_param 0@
31@ = 1
cmd_ret

:changeString
// 0@ - in string
5@ = 0 // inbracket
6@ = 0 // write offset
0AC6: 1@ = label @buffer offset
0C11: memset destination 1@ value 0x00 size 128
0C17: 2@ = strlen 0@
for 3@ = 0 to 2@
    0A8D: 4@ = read_memory 0@ size 1 virtual_protect 1
    if
    4@ <> 0
    jf break
    
    if 4@ == 0x5B // [
    then 5@ = 1
    end
    
    if 5@ == 0
    then
        000A: 1@ += 6@
        0C11: memset destination 1@ value 4@ size 1
        6@++
    end
    
    if 4@ == 0x5D // ]
    then 5@ = 0
    end
    0@++
end
0AC6: 1@ = label @buffer offset
0af8: "%s" 0xff0000 1@
ret 0

:buffer
hex
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
end
 

Parazitas

Участник
Автор темы
18
7
Nvm, thx anyway.
Код:
{$ CLEO}

0000:

repeat
wait 0
until 0AFA:

0AC8: 0 @ = allocate_memory_size 260
0AD3: 0 @ = format "{0000FF} 123456 {FF00FF} 78"

0AC8: 1 @ = allocate_memory_size 260
0AB1: @changeString param_count 4 text 0 @ FirstCharacter 123 SecondCharacter 125 memory_to_store_characters_as_text 1 @
chatmsg 1 @ -1
0A93: end_custom_thread

: changeString
{
    0AB1: call_scm_func @changeString param_count 4 text 0 @ FirstCharacter 91 SecondCharacter 93 memory_to_store_characters_as_text 1 @
    In: 0 @ = text, FirstCharacter, SecondCharacter
    Out: 1 @ = pointer to memory where characters will be stored as text

}
5 @ = FALSE // inbracket
0C17: 31 @ = strlen 0 @
    for 30 @ = 0 to 31 @
        0085: 29 @ = 0 @ // copy pointer
        005A: 29 @ + = 30 @ // add offset - make loop
        0A8D: 28 @ = read_memory 29 @ size 1 virtual_protect 1 // 28 @ is the ascii number representing character
        if
        003B: 28 @ == 1 @ // (int)
        then
            5 @ = TRUE // inbracket
        end

        if
        5 @ == FALSE // inbracket
        THEN
            0A8C: write_memory 3 @ size 1 value 28 @ virtual_protect 1
            3 @ + = 1 // move to next address
        End

        if
        003B: 28 @ == 2 @ // (int)
        then
            5 @ = FALSE // inbracket
        end
    end
0A8C: write_memory 3 @ size 1 value 0 virtual_protect 1 // null-termination
0AB2: ret 0
[/ code] [/ code] [/ code]