Change String

Code remove all string between characters..

Example.:

You have text like:
{0000FF}123456{FF00FF}78
You wanna get only:
12345678


So you need use like:
PHP:
{$CLEO}

0000:

repeat
wait 0
until 0AFA:

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

0AC8: 1@ = allocate_memory_size 1024
0AB1: call_scm_func @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

Snippet
PHP:
: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

Character ID's
http://www.asciitable.com/index/asciifull.gif

Thx @monday for teaching me even i learning slowly.
 
Last edited:

SamThapa

Active member
Joined
Jan 22, 2018
Messages
82
Reaction score
2
how ill do opposite to it example

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

need 0000FF FF00FF this
 
Top