AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   explodestring trouble (https://forums.alliedmods.net/showthread.php?t=142845)

JOSHBOX 11-10-2010 20:41

explodestring trouble
 
Hi,

I am trying to rewrite a large portion of one of my plugins so that it will read certain details from a file on plugin start, rather than having me recompile the entire plugin for minor changes. I looked into keyvalues but it seems at this point that a 2 dimensional string array would be my best bet since it is read very very frequently.

I have read for hours on the subject and I cannot figure out how to get my string from the explodestring buffer to my primary array. As you can see below, I tried a simple array=buffer; statement but I believe that is invalid for arrays. Can anyone point me in the right direction?

PHP Code:


while(!IsEndOfFile(hFile))
{
    
ReadFileLine(hFilestrLinesizeof(strLine));
    new 
String:strBreak[2][32];
    
ExplodeString(strLine";"strBreaksizeof(strBreak), sizeof(strBreak[]));
        
    
parray[fLines][0][]=strBreak[0][]
    
parray[fLines][1][]=strBreak[1][]

    
fLines++;



Silvers 11-11-2010 20:20

Re: explodestring trouble
 
http://forums.alliedmods.net/showthread.php?t=90772

meng 11-11-2010 20:20

Re: explodestring trouble
 
Why not explode directly to your "primary" array? Also, see strcopy.

Fyren 11-11-2010 20:26

Re: explodestring trouble
 
You can assign same-sized arrays to each other.

JOSHBOX 11-11-2010 20:53

Re: explodestring trouble
 
Quote:

Originally Posted by meng (Post 1347599)
Why not explode directly to your "primary" array? Also, see strcopy.

I would like to explode directly to my primary array but the explodestring function description calls for a 2D array. Do you know of a way around this?

meng 11-11-2010 22:20

Re: explodestring trouble
 
Maybe...
PHP Code:

ExplodeString(strLine";"parray[fLines], sizeof(parray[]), sizeof(parray[][])); 


JOSHBOX 11-24-2010 16:41

Re: explodestring trouble
 
I think I may be going about this in the wrong way. What I am trying to do is, read two separate items per line from a text file, at the end of the file I want to have accomplished two things:

1) Count the amount of lines I just read in the file (I tried this by incrementing fLines in my example)
2) Store both items (on each line) so that they can be referenced individually, but always as a set (These will contain a STEAMID and a string, I tried to accomplish this with a 3D array but it is turning out to be more complex that I think it needs to be)

I looked into keyvalues as an alternative but I only have a few items that need to be stored, and they will be accessed very frequently, so I believe storing this information as strings would be faster for this purpose.

Can anyone advise me on a better approach to accomplish my goals?

JOSHBOX 11-30-2010 18:04

Re: explodestring trouble
 
Sorry, I'm not trying to bump here, but I am still stuck on this. If anyone could advise me on a better approach than this overly complicated 3d array. Like I mentioned before, this data will be accessed many times per minute using a three-expression for loop.

rhelgeby 11-30-2010 18:33

Re: explodestring trouble
 
Have a look at keyvalues again. Use keyvalue format in files. When loading, parse them into an enum structure with arrays (enum structure example: http://forums.alliedmods.net/showthr...96#post1023296).

Then you can loop through and read/write to arrays without having to worry about performance.

meng 11-30-2010 23:20

Re: explodestring trouble
 
What he said!!! ^ ^ ^


All times are GMT -4. The time now is 06:21.

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