|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 06:00:01 2025 UTC |
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: