Programing

Batch Set Var From Application Output

I have been looking for this line of code for a while. I needed to set a var in a batch script to be the output from an application.

FOR /F "tokens=*" %%R IN ('PROGRAM.EXE /SWITCH') DO SET VAR=%%R

My first attempt was something like this

application > ~tmpFile
set /p var= < ~tmpFile del ~tmpFile

This post is a prequel to simple mysql backup script for windows.

Tags:

Thursday, December 11th, 2008 Programing Comments Off on Batch Set Var From Application Output

Pigs Can Fly

Php is so loosely typed that true==false in php.

$a = ‘foo’;
$b = 0;
if ( $a == true && $b == false && $a == $b ) {
echo “Pigs Can Fly”;
}

Produces “Pigs Can Fly”.
Strings are considered true if they are not empty or null. so ‘foo’==true would be true==true ie true
Numbers are considered false if they are 0. so 0 == false is false == false ie true
As for the last point this still fascinates me.
Because there are no numbers in variable $a, is set to 0, therefore int 0 == int 0.

Source

Tags:

Wednesday, November 12th, 2008 Programing Comments Off on Pigs Can Fly