Raised This Month: $ Target: $400
 0% 

Parsing help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
c2d22
Junior Member
Join Date: Feb 2013
Location: Albania
Old 05-24-2014 , 00:44   Parsing help
Reply With Quote #1

Question :-
PHP Code:
power class ability weapon 
Note - The amount of argument in the line will differ , it can go long !

So what i want is to parse the above line , and grab all the data in a dynamic array . Problem is amount of argument in the line is unidentified .
It can be
PHP Code:
power class ability weapon nothing asdjas sdhs zxnxzn 
How can i parse this type data which can be parsed unidentified times and push them into dynamic array?
c2d22 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-24-2014 , 08:55   Re: Parsing help
Reply With Quote #2

You need to lay out some type of rules for this data ie. some consistent ordering, or prefix each data item with an identifier POWER-powervalue CLASS-theclass. A computer can only do what you tell it to do, there's no magic way for it to know what you're trying to accomplish.

Looking at your second example, are the types of arguments dynamic, or only the data items belonging to each type dynamic?

If you wanted to do like "100 1 55 AWP GLOCK HEGRENADE" (100=power, 1=class, 55=ability, then a list of weapons) then this is simple.

Give some real-life example datas so we can better understand what needs to be parsed.
__________________

Last edited by Bugsy; 05-24-2014 at 08:55.
Bugsy is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-24-2014 , 09:35   Re: Parsing help
Reply With Quote #3

What Bugsy said.

You didn't tell us what you want to do, but if you just want to push mixed data into a dynamic array, why not just use ArrayPushArray / ArrayGetArray?

PHP Code:
enum _ArrayData
{
   
_Data_Power,
   
_Data_Class16 ],
   
_Data_Ability256 ],
   
_Data_Weapon
}

new Array: 
g_aArray
// ...
g_aArray ArrayCreateArrayData )

// ...

new aDataArrayData ]
aData_Data_Power ] = 1
aData
_Data_Class ] = "awesome class"
// ...
ArrayPushArrayg_aArrayaData 

Last edited by Backstabnoob; 05-24-2014 at 09:36.
Backstabnoob is offline
c2d22
Junior Member
Join Date: Feb 2013
Location: Albania
Old 05-24-2014 , 15:19   Re: Parsing help
Reply With Quote #4

Any ways i figured it out myself.
Note - i used "!" to differentiate the arguments
PHP Code:
new left[10] , right[20] ,count,,Array:in

for(a=<= charsmax(input) ; a++)
    if(
input[a] == '!' )
    
count++

for(
;  <= counta++)
{
    
strtok2(input,left,charsmax(left),input,charsmax(input), '!',TRIM_FULL)
    if(!
in)
    
in ArrayCreate()

    
ArrayPushString(in,left)


Last edited by c2d22; 05-24-2014 at 15:27.
c2d22 is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-24-2014 , 15:58   Re: Parsing help
Reply With Quote #5

Glad to see you took the time to read my post.
Backstabnoob 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 09:35.


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