I am a beginner in F# and so I will declare the problem a little further in hope someone can help me. Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Last login: Tue Jan 11 17:09:39 on ttys000
Juergen-Dabels-iMac:~ jdabel$ cd /Users/jdabel/Desktop/Gtk_Test 
Juergen-Dabels-iMac:Gtk_Test jdabel$ fsi
Microsoft (R) F# 2.0 Interactive build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> #load "/usr/lib/fsharp/load-gtk.fsx" "Program.fs";;
[Loading /usr/lib/fsharp/load-gtk.fsx
 Loading /Users/jdabel/Desktop/Gtk_Test/Program.fs]
namespace FSI_0002
namespace FSI_0002
  val window : Gtk.Window
  val vBox : Gtk.VBox
  val closeButton : Gtk.Button
  val label : Gtk.Label
> #quit;;
- Exit...
Juergen-Dabels-iMac:Gtk_Test jdabel$ fsc -o Hello-Gtk.exe /usr/lib/fsharp/load-gtk.fsx Program.fs
Microsoft (R) F# 2.0 Compiler build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
/usr/lib/fsharp/load-gtk.fsx(16,1): error FS0039: The namespace or module 'fsi' is not defined
Juergen-Dabels-iMac:Gtk_Test jdabel$ 
By on 1/11/2011 8:35 AM ()

The "fsi" object

[link:msdn.microsoft.com]

is only available in F# interactive, not in compiled apps. You might omit that, or if you are using e.g. .CommandLineArgs

[link:msdn.microsoft.com]

then switch to the compiled version; in general, read the advice here

[link:msdn.microsoft.com]

for dealing with minor differences between scripting and compiled apps.

By on 1/11/2011 10:18 AM ()

Thank you for tips, but I can't get it work. I Tried your sample with my Terminal (bash) and got:

1
2
3
4
5
6
7
8
9
10
11
Juergen-Dabels-iMac:~ jdabel$ cd /Users/jdabel/Desktop

Juergen-Dabels-iMac:Desktop jdabel$ fsc -a MyAssembly.fs

Microsoft (R) F# 2.0 Compiler build 2.0.0.0

Copyright (c) Microsoft Corporation. All Rights Reserved.

/Users/jdabel/Desktop/MyAssembly.fs(1,1): error FS0222: Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'

Juergen-Dabels-iMac:Desktop jdabel$

Please enlighten me.

Thank you

By on 1/13/2011 5:57 AM ()

If you're building a library you need to add a top level module declaration with an optional namespace. The same rule applies for multiple files application. You can omit the top level module declaration in single file applications. Just add the following line as a first declaration in your library:

module MyAssembly

By on 1/13/2011 6:45 AM ()

I think, I didn't declare what I sought:

Build and Run files with F# and Gtk and MonoDevelop, like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
open System

open Gtk

Application.Init ()

let window = new Gtk.Window ("F# Gtk")

let vBox = new Gtk.VBox ()

let closeButton = new Gtk.Button ()

let label = new Gtk.Label ("Hello World!")

window.WindowPosition <- Gtk.WindowPosition.Center ...

and in a second file "#load-gtk.fsx"

Perhaps this clears my intentions

Thank you

By on 1/14/2011 4:53 AM ()

Thank you,

but i had to insert in the first line of the fsx file:

1
#r "MyAssembly.dll"

for me as beginner it was not so clear, I had some trials to get through.

By on 1/13/2011 9:25 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper