Raised This Month: $ Target: $400
 0% 

dynamic array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-19-2013 , 01:14   dynamic array
Reply With Quote #1

May be this question has asked before a few times, but I have not found anything useful.

What I'm doing is reading users.ini file and storing admins name and id in double dimension array. Now I cant assign array size for number of admins in the file (ie: No of lines in users.ini). I have to calculate the number of lines in the file first and then create that size of array.

In C I've done this with malloc but that is not supported by PAWN. Instead of hardcoding users.ini max line can it be done anyway ?
hypheni is offline
Send a message via Skype™ to hypheni
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-19-2013 , 01:21   Re: dynamic array
Reply With Quote #2

AMXX uses CellArrays to do this, why can't you?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 01-19-2013 , 01:22   Re: dynamic array
Reply With Quote #3

check natives in cellarray.inc
__________________
Impossible is Nothing
Sylwester is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-19-2013 , 02:05   Re: dynamic array
Reply With Quote #4

oh got it.

PHP Code:
    new myArray  //global
    
myArray ArrayCreate(32)

    while(!
feof(file))
    {
        
fgets(filelinea127)
        
ArrayPushString(Array:myArraylinea)
    } 
The above piece of code means dynamic sized array created with each cell limits of 32 chars. Using ArrayPushString we can grow its size as per requirement.
hypheni is offline
Send a message via Skype™ to hypheni
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-19-2013 , 02:23   Re: dynamic array
Reply With Quote #5

You should tag the array variable with "Array:" when it is created.
__________________
fysiks 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 13:26.


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