expanding the program...

From: Date: Tue, 29 Jan 2002 21:16:27 +0000
Subject: expanding the program...
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-1065@lists.php.net to get a copy of this message
I made a bit more on my program and sure got some more problems. First function is called when you choose connect on menu and updates the main_label text box with output from connection. Second is called when you press a button on the input_label input text (I did this with button press because I still don't know how to call a event when you press enter on a input. The big problem I have now is that even that send_input reconizes fp as resorse #8 it dosen't send the data as should on fputs. This problem usually is due to $fp being called as global (for what I know it dosen't like being used that way) so it should only be used on function number one. In this case, is there a way to put function 2 inside function 1? In other words, there is a way that a event can be inserted on the middle of a function instead of being linked to it's own function? If not (as I belive) is there any way to use $fp as global or other way to do this? (Sorry if I could not explain it well) function on_connect_menu_activate() {
       global $main_label, $fp;
       $server_name = "moo.ufsm.br";
       $port_nr = 7777;
       $fp = fsockopen($server_name, $port_nr, &$errno, &$errstr) or die("$errno: $errrstr");
       set_socket_blocking($fp, 0);
       while ($fim != 1) {
               while (gtk::events_pending()) {
                       gtk::main_iteration();
               }
               if ($timeout > 6000) {
                       $fim = 1;
                       fclose($fp);
                       die("TIMEOUT");
               }
               $msg = fgets($fp, 100);
               $pos = $main_label->get_length();
               $main_label->insert_text($msg,$pos);
               usleep(400);
       }
} function send_input() {
       echo("FUNCTION");
       global $input_label, $fp;
       if (!$fp) {
               echo("No connection!");
       } else {
               $msg = $input_label->get_text();
               echo("MSG: $msg\n FP: $fp\n");
               fputs($fp, $msg);
       }
} -- Iuri Fiedoruk, Santa Maria, RS, Brasil.

« previous php.gtk.general (#1065) next »