Saturday, November 9, 2013

Checking empty variable - Batch Script

There is a tricky way to check whether a variable is empty or not in Batch script. Just have a look at the below example:


if x%TEST% == x echo empty string


In this example, the variable TEST is added with a value x and checking whether the concatenation of x and TEST is still x or not. If its still x which means TEST didn't have any value in it. Otherwise it had a value.


Simple, isn't it?


No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...