What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Determining Empty variables

Determining Empty variables
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Determining Empty variables
To make a function which acts exactly like the empty() function in PHP, you'll have to go a bit further, as stated in the PHP documentation:
quote:
Source: http://www.php.net/manual/en/function.empty.php

The following things are considered to be empty:
  • "" (an empty string)
  • 0 (0 as an integer)
  • "0" (0 as a string)
  • NULL
  • FALSE
  • array() (an empty array)
  • var $var; (a variable declared, but without a value in a class)

Depending on what you want to do, you can choose which "kind of emptiness" you want to check:
  • If it's a number, boolean, undefined or NULL variable, you can simply use if(!variable)
  • If it's a string, you can compare it to an empty string with if(variable === "")
  • If it's an array, you can check if it's empty with if(variable.length === 0)
  • etc...

This post was edited on 04-28-2008 at 04:14 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
04-28-2008 04:14 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Determining Empty variables - by le-foot on 04-28-2008 at 10:36 AM
RE: Determining Empty variables - by Skarbo on 04-28-2008 at 10:41 AM
RE: Determining Empty variables - by matty on 04-28-2008 at 01:20 PM
RE: Determining Empty variables - by Matti on 04-28-2008 at 04:14 PM
RE: Determining Empty variables - by vikke on 04-28-2008 at 04:41 PM
RE: Determining Empty variables - by matty on 04-28-2008 at 05:55 PM
RE: Determining Empty variables - by John Anderton on 04-28-2008 at 06:00 PM
RE: RE: Determining Empty variables - by vikke on 04-29-2008 at 05:05 PM
RE: Determining Empty variables - by MeEtc on 04-28-2008 at 10:10 PM
RE: Determining Empty variables - by Stigmata on 04-28-2008 at 10:49 PM
RE: Determining Empty variables - by Matti on 04-29-2008 at 04:30 PM
RE: Determining Empty variables - by WDZ on 04-29-2008 at 05:46 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On