AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Check a variable (https://forums.alliedmods.net/showthread.php?t=27023)

Cadav0r 04-13-2006 09:14

[SOLVED] Check a variable
 
Hello

I want to verify if a variable is empty or not

I try this but it doesn't work :
Code:

new reason[32]
if (!reason[32]) {
    ...
}


Xanimos 04-13-2006 09:16

if(!reason[0])

doing it your way it will see if the last character is 0 which will always be true.

Cadav0r 04-13-2006 09:46

Huuummm

Ok thanks (+karma)

PM 04-13-2006 09:59

In fact, doing it his way won't do that either because the last valid index in a 32-elements array is 31; so reason[32] will be either caught by the compiler (it should), or it will cause an out-of-bounds runtime error.

Suicid3 is right, if the first character (index 0) is zero, the string is empty.

Xanimos 04-13-2006 10:02

Hello PM[/code]
Code:

AM


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

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