Novice needs help with FX Ruby

Hi,

I have very limited programming experience but am trying to figure out
Ruby. Can someone please help me decipher this simple program found
in the samples included with FXRuby: ( The tutorial located here
http://www.fxruby.org/doc/tutorial1.html was of some help, but I am
still not getting it)

#!/usr/bin/env ruby

require “fox”

include Fox

application = FXApp.new(“Hello”, “FoxTest”)
application.init(ARGV)
main = FXMainWindow.new(application, “Hello”, nil, nil, DECOR_ALL)
FXButton.new(main, “&Hello, World!”, nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()

  1. what is this nil, nil, DECOR_ALL about?
  2. FX::ID_QUIT ?
  3. PLACEMENT_SCREEN ?
  4. What is contained in the Fox.so file? How can I view its contents?

Thanks in advance

Just so you know, this is ruby, but mostly calls the the FXruby
fox gui extension to ruby.

Hi,

I have very limited programming experience but am trying to figure out
Ruby. Can someone please help me decipher this simple program found
in the samples included with FXRuby: ( The tutorial located here
http://www.fxruby.org/doc/tutorial1.html was of some help, but I am
still not getting it)

#!/usr/bin/env ruby

require “fox”

include Fox

application = FXApp.new(“Hello”, “FoxTest”)
application.init(ARGV)
main = FXMainWindow.new(application, “Hello”, nil, nil, DECOR_ALL)
FXButton.new(main, “&Hello, World!”, nil, application, FXApp::ID_QUIT)
application.create()
main.show(PLACEMENT_SCREEN)
application.run()

These are all FOX specific items. Look at fox-toolkit.org for
documentation of the FOX toolkit in general and
http://www.knology.net/~lyle/fox/1.0/api/

For specific API documentation.

  1. what is this nil, nil, DECOR_ALL about?
  2. FX::ID_QUIT ?
  3. PLACEMENT_SCREEN ?
  4. What is contained in the Fox.so file? How can I view its contents?

You can ask ruby itself:
ruby -rfox -e “Fox.constants.each { |con| puts con}”

Or more clearly sorted:
ruby -rfox -e “Fox.constants.sort.each { |con| puts con}”

···

On Thu, Aug 29, 2002 at 02:51:06AM +0900, ck wrote:

Thanks in advance


Alan Chen
Digikata LLC

ck wrote:

  1. what is this nil, nil, DECOR_ALL about?

The line:

main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL)

instantiates a new FXMainWindow object and stores a reference to that
object in a local variable, “main”. The first argument to
FXMainWindow.new is “application”, which is a reference to the FXApp
object that you created earlier in the program. The second argument,
“Hello”, is the window title. The third and fourth arguments are
references to the “big” and “mini” icons, respectively, for your
application; since we’re passing in nil for both of these, the program
will just use some default icon for your operating system. The last
argument (DECOR_ALL) tells FOX that we want “all” of the decorations for
this window (e.g. minimize and maximize buttons, a close button, etc.)

  1. FX::ID_QUIT?

The line:

button = FXButton.new(main, "Hello, World!", nil, application, 

FXApp::ID_QUIT)

instantiates a new FXButton object and stores a reference to that object
in a local variable, “button”. Whenever that button generates an event
– namely, you push it – it will send a message to some target object.
The fourth argument of FXButton.new identifies which object is going to
get those messages; in this case it’s the application. The fifth
argument indicates what identifier (a number) will be sent along with
the message; in this case, FXApp::ID_QUIT refers to a constant (ID_QUIT)
defined in the FXApp class that tells the application to shut down. So,
in other words, clicking the “Hello, World!” button will cause the
application to quit.

  1. PLACEMENT_SCREEN?

PLACEMENT_SCREEN is just one of the placement options for the
FXMainWindow#show method, that tells it to initially place the main
window in the center of the screen. Some other commonly-used options are
PLACEMENT_CURSOR (to place it under the current cursor position) and
PLACEMENT_MAXIMIZED (i.e. window is initially maximized).

  1. What is contained in the Fox.so file? How can I view its contents?

Not sure exactly what you mean. As the tutorial states, the "fox.so"
file is just a shared library that Ruby can load dynamically.

A good source of introductory material about all this stuff is the FOX
web site, found here:

http://www.fox-toolkit.org

Click on the “Documentation” link on the left side of the home page, and
then start from the top!

Hope this helps,

Lyle

All the ruby talk recently about what language after ruby, the
Abelson/Sussman book (“Structure and Interpretation of Computer
Programs”), the PragProg/Haskell conversation etc. has gotten me in
the mood to try some Scheme in order to expand my programming
repetoir somewhat. Is there a canonical place to get an interpreter
for windows, or will any of the ones I see from Google suffice?

I’m essentially going to go through the Abelson book and self-direct
study is as if it were a class, so really I just need something that
will work with the examples therein, and is usable enough to do the
problems posed.

Offline replies appreciated.

···

=====

Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell


Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes

Michael Campbell wrote:

All the ruby talk recently about what language after ruby, the
Abelson/Sussman book (“Structure and Interpretation of Computer
Programs”), the PragProg/Haskell conversation etc. has gotten me in
the mood to try some Scheme in order to expand my programming
repetoir somewhat. Is there a canonical place to get an interpreter
for windows, or will any of the ones I see from Google suffice?

I’m essentially going to go through the Abelson book and self-direct
study is as if it were a class, so really I just need something that
will work with the examples therein, and is usable enough to do the
problems posed.

Offline replies appreciated.

=====

Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell


Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

Just open up the GOOGLE search engine and type SCHEME for WINDOWS and I
am sure you will get some sites.

BX

Scheme has no canonical interpreter. Try MzScheme, I recall it works fine
on windows, and it’s the one I used on my tour of the fine book. :wink:

– Nikodemus

···

On Thu, 29 Aug 2002, Michael Campbell wrote:

repetoir somewhat. Is there a canonical place to get an interpreter
for windows, or will any of the ones I see from Google suffice?

You might find something here: http://www.schemers.org/

···

On Wed, 2002-08-28 at 21:58, Michael Campbell wrote:

All the ruby talk recently about what language after ruby, the
Abelson/Sussman book (“Structure and Interpretation of Computer
Programs”), the PragProg/Haskell conversation etc. has gotten me in
the mood to try some Scheme in order to expand my programming
repetoir somewhat. Is there a canonical place to get an interpreter
for windows, or will any of the ones I see from Google suffice?

I’m essentially going to go through the Abelson book and self-direct
study is as if it were a class, so really I just need something that
will work with the examples therein, and is usable enough to do the
problems posed.

Offline replies appreciated.

=====

Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell


Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

Dr. Nathaniel Pryce, Technical Director, B13media Ltd.
Studio 3a, 22-24 Highbury Grove, London N5 2EA, UK
http://www.b13media.com

Nikodemus Siivola tsiivola@cc.hut.fi wrote in message news:Pine.GSO.4.44.0208290952240.847-100000@kekkonen.cs.hut.fi

repetoir somewhat. Is there a canonical place to get an interpreter
for windows, or will any of the ones I see from Google suffice?

Scheme has no canonical interpreter. Try MzScheme, I recall it works fine
on windows, and it’s the one I used on my tour of the fine book. :wink:

– Nikodemus

I’de second that.

DrScheme/PLT scheme/MzScheme (http://www.plt-scheme.org/) has the most
extensive libraries and the most user friendly tools and documentation
that I have found. Others that I have examined and abandoned: Chez
Scheme, MIT Scheme, 3dScheme and Scheme48. You might also have a look
at scsh (http://www.scsh.net/) which is awesome for scripting.

-pp

···

On Thu, 29 Aug 2002, Michael Campbell wrote: