php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15543 using com_* versus new COM(...) and error reporting
Submitted: 2002-02-13 12:29 UTC Modified: 2002-04-29 11:50 UTC
From: Vladimir dot Michl at hlubocky dot del dot cz Assigned:
Status: Closed Package: COM related
PHP Version: 4.1.0 OS: Windows NT 4.0/W2k
Private report: No CVE-ID: None
 [2002-02-13 12:29 UTC] Vladimir dot Michl at hlubocky dot del dot cz
Hello,

I want connect to COM server, that publish data from some application. Script run forever, but application my be started or stoped.

If I try use following script, I cannot discover if invoking object method is succesful or not. Here is script:

$tag = new COM("FLINK.TAGOBJ") or die("Unable to instanciate Flink");
while (1) {
	$bool = $tag->bind("DATETIME"); 
	if ($bool === false){
		print "Bind failed\n";
	};

	$val = $tag->read; // This function return value from binded variable
	if ($val === false){
		print "Read failed\n";
	};

	print "Val: $val\n";
	sleep(1);
};
$tag->Release();
$tag = null;


Messages "* failed" is not reported, if application not run.

The following script run correctly:

$tag = com_load("FLINK.TAGOBJ") or die("Unable to instanciate Flink");

while (1) {
	$bool = com_invoke($tag, "bind", "DATETIME"); 
	if ($bool === false){
		print "Bind failed\n";
	};

	$val = com_invoke($tag, "read"); // This function return value from binded variable
	if ($val === false){
		print "Read failed\n";
	};

	$val = com_propget($tag, "read"); // This function return value from binded variable
	if ($val === false){
		print "Propget Read failed\n";
	};

	print "Val: $val\n";

	sleep(1);
};

com_release($tag);
$tag = null;

Is this feature or bug.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-17 08:03 UTC] phanto@php.net
could you add 'var_dump($bool)' above the if's and send me the output please.
the functions should actually do the same thing as the oo api.
 [2002-02-18 03:17 UTC] Vladimir dot Michl at hlubocky dot del dot cz
Diffrent is, that $comobj->xxx return NULL if fail, but
com_* return FALSE if fail.

------------------------------------------------------
Test1:
$tag = new COM("FLINK.TAGOBJ") or die("Unable to instanciate Flink");

while (1) {
	$bool = $tag->bind("DATETIME"); 
	var_dump($bool);
	if ($bool === false){
		print "Bind failed\n";
	};

	$val = $tag->read; // This function return value from binded variable
	var_dump($val);
	if ($val === false){
		print "Read failed\n";
	};

	print "Val: $val\n";
	sleep(1);
};
$tag->Release();
$tag = null;
--------------------------------------------------
Test1 output:
X-Powered-By: PHP/4.1.0
Content-type: text/html

int(0)
<br>
<b>Warning</b>:  PropGet() failed: Nespecifikovan? chyba
 in <b>C:\php\com_test1.php</b> on line <b>15</b><br>
NULL
Val:
--------------------------------------------------
Test2:
$tag = com_load("FLINK.TAGOBJ") or die("Unable to instanciate Flink");

while (1) {
	$bool = com_invoke($tag, "bind", "DATETIME"); 
	var_dump($bool);
	if ($bool === false){
		print "Bind failed\n";
	};

	$val = com_invoke($tag, "read"); // This function return value from binded variable
	var_dump($val);
	if ($val === false){
		print "Read failed\n";
	};

	$val = com_propget($tag, "read"); // This function return value from binded variable
	var_dump($val);
	if ($val === false){
		print "Propget Read failed\n";
	};

	print "Val: $val\n";

	sleep(1);
};

com_release($tag);
$tag = null;
----------------------------------------------------------
Test2 output:
X-Powered-By: PHP/4.1.0
Content-type: text/html

int(0)
<br>
<b>Warning</b>:  Invoke() failed: Nespecifikovan? chyba
 in <b>C:\php\com_test2.php</b> on line <b>14</b><br>
bool(false)
Read failed
<br>
<b>Warning</b>:  PropGet() failed: Nespecifikovan? chyba
 in <b>C:\php\com_test2.php</b> on line <b>20</b><br>
bool(false)
Propget Read failed
Val: 


 [2002-04-29 11:50 UTC] phanto@php.net
now com_* and COM(..) should both return NULL in case of an error.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 08:01:30 2024 UTC