Run-Time Freeze "While" function.
I literally give up, i made a function which will remove all non-letters from a string.
For example i type a string : "H e 1 l l!!o" And it should clear the string and return me : "Hello" And the problem is when i add the condition string[i] < 65 (65 by ascii table is 'A' ) , then when i type my string which has one of these symbols up to 65, then it just freezes. In pawno quincy freezes and in cs 1.6 HLDS freezes and it's showing as "no response" window. Oh my fucking jesus, i first time see that kind of bullshit . I'm very tired, i tried to understand why and nothing... I sit like 3-4 hours and didn't find out the problem. Look: PHP Code:
|
Re: Run-Time Freeze "While" function.
Make it easy for yourself and use different input and output buffers, rather than modifying the input.
PHP Code:
|
Re: Run-Time Freeze "While" function.
Ohh, but this way I should create another string .But I want only to remove these characters from the string..
Really don't understand why < 65 throws error .. |
Re: Run-Time Freeze "While" function.
So if I use this stock and add also another message[192] to copy new string will it be less efficient than editing the actual one?
Because there will be 2 arrays with size 192, instead of 1. |
Re: Run-Time Freeze "While" function.
Having one or two really doesn't matter. Don't try to micro optimize. It only start to matter on functions called per frame.
|
Re: Run-Time Freeze "While" function.
Quote:
If i use "if(str[i] < 65)" and then don't use one of these characters in my string then it gives error, but as soon as i use space, or other characters which are smaller then 65 regarding ASCII table then it freezes. Really don't understand. It looks like it can't replace one of this characters with others ?? For example string "Hell o", it replaces letters but when it comes to space it freezes. wtf? letters are white and spaces are black? (kidding..) :) |
Re: Run-Time Freeze "While" function.
If you really want to do it with only one string:
Code:
A test plugin: Code:
Code:
get_result "H e 1 l l!!o" Code:
You could find this by putting some log_to_file messages and see where it crash and why. It was not related with the ASCII condition. Anyway, your function is missing some stuff(check mine) so it will likely not work. If you want to know why: Take for example: Hell33o When you remove the first 3, the second one gets on position i, but you jump to i+1 so the second "3" escape. That's why I'm doing i = i - 1 |
Re: Run-Time Freeze "While" function.
Ok , thank you very much. I needed it to use in my new plugin , you can check it here :
https://forums.alliedmods.net/showth...85#post2426485 Credits to both of you, thanks ... |
Re: Run-Time Freeze "While" function.
Hamlet, just a little suggestion.
Passing string length to RemoveAllButLetters() is a little bit awkward, because function can track the length by itself. That's like if you had to pass length to remove_quotes() or any function that takes an input string and doesn't add characters to that buffer. Here is my modified version: PHP Code:
|
Re: Run-Time Freeze "While" function.
I had in mind to do something different but changed in the last moment. Well, not like it matter.
|
All times are GMT -4. The time now is 15:31. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.