[lazarus] Learning component building blocks

Payne Thomas E CNIN payne_t at crane.navy.mil
Mon Jul 19 10:30:39 EDT 1999


I looked at it some more, and I apologize for my stupidity.  I just checked
it when the box I connected to does not respond, and no noise.

Sorry for the hasty question, and assumptions.

Tom

> -----Original Message-----
> From:	Payne Thomas E CNIN 
> Sent:	Monday, July 19, 1999 9:21 AM
> To:	'lazarus at miraclec.com'
> Subject:	RE: [lazarus] Learning component building blocks
> 
> I have looked at it some more and GTK isn't the issue.  The box I am
> talking to is sending chars back but I only opened for write.  With gtk
> fully commented out, I can add a repeat...until loop and get the chars on
> the line.  I am not sure if it the way I am opening the port, the current
> setting of the port, or the fact that the other end of the connection is
> placing chars on the line.  I think this is more of a down the road
> problem and I can let you guys continue the IDE.  I have hopes of a Serial
> Comm Component, but maybe I can focus on something like TPanel.
> 
> BTW I am still reading the GTK tutorial and converting the C (with alot of
> help from Michael [MVC] and Shane),  how much interest would there be in a
> Pascal version of the Tutorial?
> 
> Tom
> 
> 	-----Original Message-----
> 	From:	Baeseman, Cliff [SMTP:Cliff.Baeseman at greenheck.com]
> 	Sent:	Monday, July 19, 1999 8:51 AM
> 	To:	lazarus at miraclec.com
> 	Subject:	RE: [lazarus] Learning component building blocks
> 
> 	What do you mean by abnormally...
> 
> 	Cliff
> 
> 	-----Original Message-----
> 	From: Payne Thomas E CNIN [mailto:payne_t at crane.navy.mil]
> 	Sent: Sunday, July 18, 1999 4:36 PM
> 	To: lazarus at miraclec.com
> 	Subject: [lazarus] Learning component building blocks
> 
> 
> 	This is way off the latest discussions, but I am trying things on
> the ground
> 	floor.
> 	I am aiming at using FPC and LAZARUS in the real world when they are
> done,
> 	but at the moment I am trying to learn how to use the basic tools,
> at hopes
> 	to
> 	contribute for everyones benefit.
> 
> 	My simple program below was attempting to mix serial comm with a GTK
> gui.  I
> 
> 	can talk through the serial port OK by itself.  I can get the
> buttons to
> 	work by 
> 	themselves.  But when I add any gtk calls to the basic serial I/O it
> behaves
> 
> 	abnormally.
> 
> 	Anyone have a clue why gtk would interfere with the serial port?
> 
> 	Tom
> 	_______________________________________________________________
> 	      Program tdc1;
> 
> 	      Uses linux,glib,gdk,gtk,sysutils;
> 
> 	      Const myLine : String[80] = #128#00#03#21#12#164;
> 
> 	      Var myFD : Longint;
> 
> 	      procedure lcp_status_command( widget : pGtKWidget; 
> 	
> data
> 	: gpointer); cdecl;
> 	      begin
> 	          writeln('sending the command');
> 	          if length(myLine)<>fdwrite (myFD,myLine[1],
> 		
> 	Length(myLine)) then
> 	            Writeln ('Error when writing to file !');
> 	      end;
> 
> 	      procedure quit_program( widget : pGtkWidget; event :
> pGdkEvent;
> 	                               data : gpointer); cdecl;
> 	      begin
> 	          fdClose(myFD);
> 	          gtk_main_quit();
> 	      end;
> 
> 	      var
> 	        window, button, box1 : pGtkWidget;
> 
> 	      begin
> 	        myFD:=fdOpen ('/dev/cua0',Open_WrOnly);  //from fdopen
> example in
> 	FPC
> 	        if myFD>0 then
> 	          begin
> 
> 	          if length(myLine)<>fdwrite (myFD,myLine[1],
> 				Length(myLine)) then
> 	            Writeln ('Error when writing to file !');
> 
> 	{         //Taken from GTK 1.2 tutorial, section 3.3, and converted
> to .pp
> 	          //* This is called in all GTK applications. Arguments are
> 	          // parsed
> 	          // * from the command line and are returned to the
> 	          // application. */
> 	          gtk_init (@argc, @argv);
> 
> 	          //* Create a new window */
> 	          window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
> 
> 	          //* This is a new call, this just sets the title of our
> 	          // * new window to "Hello Buttons!" */
> 	          gtk_window_set_title (GTK_WINDOW (window), 'Hello
> Buttons!');
> 
> 	          //* Here we just set a handler for delete_event that
> 	          // immediately
> 	          // * exits GTK. */
> 	          gtk_signal_connect (GTK_OBJECT (window), 'delete_event',
> 	                              GTK_SIGNAL_FUNC (@quit_program),
> NULL);
> 
> 	          //* Sets the border width of the window. */
> 	          gtk_container_set_border_width (GTK_CONTAINER (window),
> 10);
> 
> 	          //* We create a box to pack widgets into.  This is
> described
> 	          // in detail
> 	          // * in the "packing" section. The box is not really
> visible,
> 	          // it
> 	          // * is just used as a tool to arrange widgets. */
> 	          box1 := gtk_hbox_new(FALSE, 0);
> 
> 	          //* Put the box into the main window. */
> 	          gtk_container_add (GTK_CONTAINER (window), box1);
> 
> 	          //* Creates a new button with the label "Button 1". */
> 	          button := gtk_button_new_with_label ('Button 1');
> 
> 	          //* Now when the button is clicked, we call the "callback"
> 	          // function
> 	          // * with a pointer to "button 1" as its argument */
> 	          gtk_signal_connect (GTK_OBJECT (button), 'clicked',
> 	                              GTK_SIGNAL_FUNC (@lcp_status_command),
> 	                                                               Nil);
> 
> 	          //* Instead of gtk_container_add, we pack this button into
> the
> 	          //  invisible
> 	          //  * box, which has been packed into the window. */
> 	          gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
> 
> 	          //* Always remember this step, this tells GTK that our
> 	          // preparation for
> 	          // * this button is complete, and it can now be displayed.
> */
> 	          gtk_widget_show(button);
> 
> 	          //* Do these same steps again to create a second button */
> 	          button := gtk_button_new_with_label ('Button 2');
> 
> 	          //* Call the same callback function with a different
> argument,
> 
> 	          // * passing a pointer to "button 2" instead. */
> 	          gtk_signal_connect (GTK_OBJECT (button), 'clicked',
> 	                              GTK_SIGNAL_FUNC (@lcp_status_command),
> 	                                                              Nil);
> 
> 	          gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
> 
> 	          //* The order in which we show the buttons is not really
> 	          //   important, but I
> 	          // * recommend showing the window last, so it all pops up
> at
> 	          // once. */
> 	          gtk_widget_show(button);
> 
> 	          gtk_widget_show(box1);
> 
> 	          gtk_widget_show (window);
> 
> 	          //* Rest in gtk_main and wait for the fun to begin! */
> 	          gtk_main ();
> 	}
> 
> 	          end
> 	   else
> 	            writeln('Error opening File');
> 	      end.
> 
> 	_________________________________________________________________
> 	     To unsubscribe: mail lazarus-request at miraclec.com with
> 	                "unsubscribe" as the Subject
> 	    archives at http://www.miraclec.com/list_archives/lazarus
> 
> 	_________________________________________________________________
> 	     To unsubscribe: mail lazarus-request at miraclec.com with
> 	                "unsubscribe" as the Subject
> 	    archives at http://www.miraclec.com/list_archives/lazarus






More information about the Lazarus mailing list