note 49988 added to class.com

From: Date: Mon, 14 Feb 2005 20:22:24 +0000
Subject: note 49988 added to class.com
Groups: php.notes 
Request: Send a blank email to php-notes+get-85028@lists.php.net to get a copy of this message
Basic Windows IO If you are using a command line (CLI) version of PHP on a Win32 platform, you might like to have a simple graphical interface to get input and output. The following gives an illustration for both. <?php // first we get some input $oScript = new COM("MSScriptControl.ScriptControl"); $oScript->Language = "VBScript"; $title = "I/O Demo: Input half"; $initial = "Change this value"; $prompt = "Please enter a value"; $code = <<<EOF Function getInput() inVal = InputBox("$prompt", "$title", "$initial") getInput = inVal 'how return values are assigned in VB End Function EOF; $oScript->AddCode($code); $input = $oScript->Eval("getInput()"); if (gettype($input)=="NULL") $input = "Input box was cancelled"; // now we show some output $oWSH = new COM("WScript.Shell"); $title = "I/O Demo: Output half"; $timeout = 2; // 0 for no timeout $style = 0 + 48; // buttons to show + alert symbol $oWSH->Popup($input, $timeout, $title, $style); ?> This is example is overblown for illustrative purposes. The whole input part collapses if the amount of code used is a single statement. So, this would have sufficed: $code = "InputBox(\"$prompt\", \"$title\", \"$initial\")"; $input = $oScript->Eval($code); This technique exposes quite a bit of scripting power tied into the Windows operating system and VBScript. However, you should have a really specific reason for using it since VBScript tends to be dog slow when compared to PHP in my tests. Simple IO like this is good, however, and the popup size can be quite large. Furthermore, this could be a viable route to go for accessing WinAPI's. http://www.ss64.com/wsh/popup.html shows some documentation for $oWSH->Popup Csaba Gabor from Vienna ---- Manual Page -- http://www.php.net/manual/en/class.com.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49988 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49988&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49988&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49988&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49988&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49988&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49988&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85028) next »