From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA24880; Tue, 22 Apr 2003 15:28:27 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA25095 for ; Tue, 22 Apr 2003 15:28:26 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h3MDSPv09525 for ; Tue, 22 Apr 2003 15:28:25 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 197xou-0003U0-00 for ; Tue, 22 Apr 2003 14:28:24 +0100 Date: Tue, 22 Apr 2003 14:28:24 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] lablgtk newbie question Message-ID: <20030422132824.GA12408@redhat.com> References: <20030422105529.GA11783@redhat.com> <20030422221215C.garrigue@kurims.kyoto-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030422221215C.garrigue@kurims.kyoto-u.ac.jp> User-Agent: Mutt/1.5.3i From: Richard Jones X-Spam: no; 0.00; caml-list:01 lablgtk:01 newbie:01 gtkinit:01 usr:01 descriptor:01 operand:01 unexpected:01 prerr:01 endline:01 show-stopper:01 monad:01 haskell:01 gmain:01 gwindow:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Thanks everyone. I'm now using: ocaml -w s -I +lablgtk lablgtk.cma gtkInit.cmo editor.ml I notice that I can't put #!/usr/bin/ocaml -w s -I +lablgtk lablgtk.cma gtkInit.cmo at the beginning of my program. It complains of: Couldnt get a file descriptor referring to the console Could not get a file descriptor referring to the console Couldnt get a file descriptor referring to the console Could not get a file descriptor referring to the console Couldnt get a file descriptor referring to the console Could not get a file descriptor referring to the console ./editor.ml: line 8: let: =: syntax error: operand expected (error token is "=") ./editor.ml: line 9: syntax error near unexpected token `"Unimplemented: "' ./editor.ml: line 9: ` prerr_endline ("Unimplemented: " ^ msg);;' Strange, but not a show-stopper. I've also rewritten the program and worked out what the problem was with ;; and ;. I'm assuming that ';' on its own is just a sequence point, kind of like the monad stuff in Haskell (?) And I'm using let ... in as a short-hand for a local variable (except, of course, I'm aware that it's not _really_ "variable"). My program looks like this now. Comments on style are welcome. Rich. open GMain open GWindow open GdkKeysyms let unimplemented msg = prerr_endline ("Unimplemented: " ^ msg);; let menu_new_blank_page () = unimplemented "New blank page function selected";; let menu_search () = unimplemented "Search function selected";; let menu_cut () = unimplemented "Cut function selected";; let menu_copy () = unimplemented "Copy function selected";; let menu_paste () = unimplemented "Paste function selected";; let main () = (* Main window *) let window = GWindow.window ~width:500 ~height:300 ~title:"Editor" () in let vbox = GPack.vbox ~packing:window#add () in window#connect#destroy ~callback: Main.quit; (* Menu bar *) let menubar = GMenu.menu_bar ~packing:vbox#pack () in let factory = new GMenu.factory menubar in let accel_group = factory#accel_group in let pages_menu = factory#add_submenu "Pages" in let edit_menu = factory#add_submenu "Edit" in (* Pages menu *) let factory = new GMenu.factory pages_menu ~accel_group in factory#add_item "New blank page" ~key:_N ~callback: menu_new_blank_page; factory#add_item "Search ..." ~key:_S ~callback: menu_search; (* Edit menu *) let factory = new GMenu.factory edit_menu ~accel_group in factory#add_item "Cut" ~key:_X ~callback: menu_cut; factory#add_item "Copy" ~key:_C ~callback: menu_copy; factory#add_item "Paste" ~key:_V ~callback: menu_paste; (* Display the windows and enter Gtk+ main loop *) window#show (); Main.main ();; (* Run the main program *) main ();; -- Richard Jones, Red Hat Inc. (London) and Merjis Ltd. http://www.merjis.com/ http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj MONOLITH is an advanced framework for writing web applications in C, easier than using Perl & Java, much faster and smaller, reusable widget-based arch, database-backed, discussion, chat, calendaring: http://www.annexia.org/freeware/monolith/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners