AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ignore empty rows (https://forums.alliedmods.net/showthread.php?t=100019)

Sn!ff3r 08-11-2009 15:15

Ignore empty rows
 
Hi.

PHP Code:

new myarray[10][32]

public function()
{
    for ( new 
08i++)
    {
        
formatex(myarray[i], 31"anytext")
    }


Now two last rows are empty. How to count only set rows ? sizeof will return 10.

Bugsy 08-11-2009 15:25

Re: Ignore empty rows
 
Does this array hold strings? If not, what kind of data is it?

If strings:
PHP Code:

new myarray[10][32]

public function()
{
    for ( new 
sizeofmyarray ) ; i++ )
        if ( 
myarray[i][0] )
            
formatexmyarray[i] , 31"anytext")



Sn!ff3r 08-13-2009 13:26

Re: Ignore empty rows
 
No, not that!

I want to check real array (not empty rows) size, not fill it.

Jon 08-13-2009 13:46

Re: Ignore empty rows
 
strlen( szString[] ) ?

AntiBots 08-13-2009 14:10

Re: Ignore empty rows
 
more faster do MyArray[i][0] == '\0' ( '^0' )

[ --<-@ ] Black Rose 08-13-2009 14:22

Re: Ignore empty rows
 
...which is the same as ( ! MyArray[i][0] ).

Sn!ff3r explain more.

Bugsy 08-13-2009 19:42

Re: Ignore empty rows
 
Unfortunately, there is no sizeof-esque operator that will return only array elements that contain data -- you will need to create it yourself.

If you are working with an array of strings then the above will be the simplest method. If the array holds integers (or w\e data) then you will have to determine the best way -- or give us more info on what kind of data you're working with and we can help.


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

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