[snippet]remove digits

[shcode=cpp]
0@ = 0x29
repeat
    wait 0
    0@ += 0x01
    if 0C2A: 2@ = strchr 4@ char 0@
    then
        repeat
            wait 0
            0A8C: write_memory 2@ size 1 value 0x90 virtual_protect 0
        until 8C2A: 2@ = strchr 4@ char 0@
    end
until 0@ == 0x39 
[/shcode]

4@ - text
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
It uses sampfuncs... kinda useless. Atleast try to make a version without sampfuncs.


Code:
0AC8: 0@ = allocate_memory_size 1024
0AD3: 0@ = format "This3 is one St54ring with n1mb3rs."
for 1@ = 0 to 1024
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0 // read current char
    if or
    2@ > 48 // Number 0
    2@ < 57 // Number 9
    then    
        0A8C: write_memory 0@ size 1 value 32 virtual_protect 0
        // or just empty it:
        //0A8C: write_memory 0@ size 1 value 0 virtual_protect 0
    end
    0@ += 1 // next char
end
0AC9: free_allocated_memory 0@
not sure if it works but thats what i came up with without testing^^
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
Opcode.eXe said:
It uses sampfuncs... kinda useless. Atleast try to make a version without sampfuncs.


Code:
0AC8: 0@ = allocate_memory_size 1024
0AD3: 0@ = format "This3 is one St54ring with n1mb3rs."
for 1@ = 0 to 1024
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0 // read current char
    if or
    2@ > 48 // Number 0
    2@ < 57 // Number 9
    then    
        0A8C: write_memory 0@ size 1 value 32 virtual_protect 0
        // or just empty it:
        //0A8C: write_memory 0@ size 1 value 0 virtual_protect 0
    end
    0@ += 1 // next char
end
0AC9: free_allocated_memory 0@
not sure if it works but thats what i came up with without testing^^
don't u need to check the size of the string to improve the speed?
60mem it's enough for your string :p
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,104
Solutions
5
Reaction score
882
Location
Lithuania
Can work without SAMPFUNCS
PHP:
{
   call @RemoveDigitsFromString 1 stringPointer 1@
}
:RemoveDigitsFromString
0C17: 31@ = strlen 0@
31@ -= 1
0085: 28@ = 0@ // copy base string pointer
005A: 28@ += 31@ //byte ending the string (0)
0085: 27@ = 0@ // copy of the base string pointer (needed for manipulation to rewrite the string without the digits, mayme 0@ could be used for that but because It\'s used in the "for loop" I don\'t want to risk and cba to check whether manipulating it affects the loop)
  for 30@ = 0@ to 28@ // 30@ = pointer to each byte in the string
  0A8D: 29@ = read_memory 30@ size 1 virtual_protect 1
      if and // if is equal or higher than "0" in ascii, and if is equal or lower than "9" in ascii (http://www.asciitable.com/index/asciifull.gif)
      0029:   29@ >= 48
      002B:   57 >= 29@
      then
      //do nothing if it\'s a digit
      else
      0A8C: write_memory 27@ size 1 value 29@ virtual_protect 1
      27@++ //27@ increases only if it\'s not a digit, making sure digits won\'t be rewritten  
      end      
  end
  0A8C: write_memory 27@ size 1 value 0 virtual_protect 1 //last byte set to 0 to end the string (27@ is already increased by 1 by the opcode within the loop)
//the remaining bytes (probably 3) could be set to 0 but let\'s live dangerously and leave them alone
ret 0 //not need to return the string because we didn\'t pass the string itself to a function (the pointer of it was passed meaning that the memory at its address was and will stay rewritten)

Credits.:
@monday
 
Last edited:

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
Code:
:Remove_Digits
0085: 5@ = 0@ // (int)
0085: 6@ = 1@ // (int)
0@ = 0x30
alloc 4@ = 1000
if 1@ == 0
then 0AF4: 4@ = read_string_from_ini_file "cleo\CopyChat.ini" section "Texts" key "Original_Text"
else 0AF4: 4@ = read_string_from_ini_file "cleo\CopyChat.ini" section "Texts" key "Original_Title"
end
repeat
    wait 0  
    if 0C2A: 2@ = strchr 4@ char 0@
    then
        repeat
            wait 0
            0A8C: write_memory 2@ size 1 value 0x90 virtual_protect 0
        until 8C2A: 2@ = strchr 4@ char 0@
    end
    0@ += 0x01
until 0@ == 0x3A
if 6@ == 0
then
    Dialog.SetControlText(5@, 0, 4@)
    0AF5: write_string 4@ to_ini_file "cleo\CopyChat.ini" section "Texts" key "Original_Text"
else
    Dialog.SetControlText(5@, 10, 4@)
    0AF5: write_string 4@ to_ini_file "cleo\CopyChat.ini" section "Texts" key "Original_Title"
end
free 4@
ret 0

it will only remove the digits
 
Top