Raised This Month: $ Target: $400
 0% 

string reading problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpaceRip
Junior Member
Join Date: Aug 2012
Old 08-17-2012 , 08:18   string reading problems
Reply With Quote #1

Hello, i try to do something here

if text contains \x then do something and skip text "\x"
here is code
PHP Code:
            for (0127y++)
            {
                if ( !
m[y] )
                    break

                if( 
)
                {
                    
0
                    
continue
                }

                if ( 
m[y] == '\')
                {    
                    d = 1
                    c = str_to_num(m[y + 1])
                    print( i, "color %d - m: %s", c, m[y + 1] )
                    continue
                }

code run in loop, it check m[128] string variable the problem is that this fails somehow
sometime it crab a wrong thing, m[23] == '\' , m[24] == '1' , m[25] == '3'
and i will got 3 with this code, how is this possible?

Last edited by SpaceRip; 08-17-2012 at 08:20. Reason: more code
SpaceRip is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-17-2012 , 13:41   Re: string reading problems
Reply With Quote #2

if(contain(m, "/x") != -1)
{
//The string contains /x
//this is what we do
}
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
SpaceRip
Junior Member
Join Date: Aug 2012
Old 08-17-2012 , 14:08   Re: string reading problems
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
if(contain(m, "/x") != -1)
{
//The string contains /x
//this is what we do
}
how you do this in loop with checking every sting char one by one?
PHP Code:
if(contain(m"/x"
it take all text what is inside m variable, i can controll or can not know where the place was where that /x.
SpaceRip is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-17-2012 , 14:23   Re: string reading problems
Reply With Quote #4

You don't loop it, that is the point. If you need to know where in the string /x is, cache the return of contain and use that. Contain returns the index of where the second argument is. Check out the wiki. then you'd take that index, add 2, and that is the start of w/e you're looking for.

Show the whole function so i know more of what you're trying to do.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-17-2012 , 16:01   Re: string reading problems
Reply With Quote #5

Are you trying to convert \x## from HEX to an ASCII character?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SpaceRip
Junior Member
Join Date: Aug 2012
Old 08-18-2012 , 14:59   Re: string reading problems
Reply With Quote #6

Quote:
Originally Posted by Liverwiz View Post
You don't loop it, that is the point. If you need to know where in the string /x is, cache the return of contain and use that. Contain returns the index of where the second argument is. Check out the wiki. then you'd take that index, add 2, and that is the start of w/e you're looking for.

Show the whole function so i know more of what you're trying to do.
i think that "contain" function works same way as i tring to do but the question is why i fail.
So what i want to do is "Too much" to talk about it, many systems of mine will use that code.
But now on i just try to create code what can do Following things.
Sort tag-ed data into the correct string variable.
Add x char to all string variable where i sort data except that one what is in progress right now.
PHP Code:
int c // correct variable bound
int i

for ( 0hmax;i++ )
    if ( 
== )
        break 
// or // continue 
if it is x char then store it too all variable(s) bounds.

I really need to use loop and do every char one by one only then i can get unlimited opportunity, you never know what you need to do next time.
Its a big script and all my functions must have unlimited opportunity, ohter ways i will keep writing a code and it will get really too huge.
For no own, i dont know that if the size of the all plugin code takes more cpu if many functions is used very rarely, so im trying to keep it safe just for case.

Quote:
Originally Posted by Exolent[jNr] View Post
Are you trying to convert \x## from HEX to an ASCII character?
No
SpaceRip is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 08-18-2012 , 15:21   Re: string reading problems
Reply With Quote #7

strfind be an option ?

Well if you post whole funcion you will get a better answer.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 08-18-2012 at 15:23.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-18-2012 , 19:10   Re: string reading problems
Reply With Quote #8

show your whole code. No one knows what you're trying to do. Because there are natives that do this better.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-19-2012 , 08:13   Re: string reading problems
Reply With Quote #9

you could use regex to find \x## from string and use replace() to replace that with empty string
jimaway is offline
SpaceRip
Junior Member
Join Date: Aug 2012
Old 08-21-2012 , 16:26   Re: string reading problems
Reply With Quote #10

**Code removed**

I try one more time to make working code, this is just too badly coded.

Last edited by SpaceRip; 08-21-2012 at 16:42.
SpaceRip is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode