Jump to content
  • 0

how to check if var empty


Vincent

Question


  • Group:  Members
  • Topic Count:  130
  • Topics Per Day:  0.03
  • Content Count:  528
  • Reputation:   18
  • Joined:  09/11/12
  • Last Seen:  

hello,

how can i check if a variable is empty?

 

my code(not all):

query_sql "SELECT `last_mac` FROM `login` WHERE `char_id` = " + getcharid(0) + "", .@lastmac;

the fild "last_mac" can be empty because of this

COLUMN `last_mac` VARCHAR(18) NOT NULL DEFAULT ''

 But how can i check this with a if? This dont work

if (.@lastmac == )
{
bla bla
}
Edited by Vincent
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

your script will end up failed...

  1. variable is not saved as string
  2. login table dont have char_id column

it should be like this

query_sql( "SELECT `last_mac` FROM `login` WHERE `account_id` = "+getcharid(3), .@lastmac$ );

then to check if the MAC address is empty or not..

if( .@lastmac$[.@i] == "" ){
   // mac address is empty
}
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  46
  • Reputation:   1
  • Joined:  03/04/17
  • Last Seen:  

So 

 if (!.var)

means 'if var is empty' ?

If I want it to be true if not empty, should i only use :

if (.var)

Or should I use

if (!(!.var))

?

 

I was afraid that !.var would only check if .var exists, not validate its value.

Edited by klesler
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  209
  • Topics Per Day:  0.05
  • Content Count:  892
  • Reputation:   27
  • Joined:  12/09/11
  • Last Seen:  

if(!.@lastmac )
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  130
  • Topics Per Day:  0.03
  • Content Count:  528
  • Reputation:   18
  • Joined:  09/11/12
  • Last Seen:  

Thanks both

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...