DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    3

    SML.NET start-up

    Hi there,

    I have been struggling trying to find a way to start properly using SML.NET
    I jsut want to try a Hello World program and I am not sure how to find that simple information.
    I start a new SML project in Visual Studio .NET and I have the script file and the sml file. There is the main function, but I do not know where to put my code...
    There seems to be no documentation at all for the beginner and not .NET familiar people and this is regretable...
    Anyway, I need some help to start up on the right tracks.

    Send me links, docs, guidance. That would be much appreciated

    Thankie,
    Emmi

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Aug 2007
    Posts
    3
    First of all thank you so much for you quick reply.

    I have that doc of course, but the short description of the VS environment did not help me. It does not explain really what I need to do with the files that are automatically created for me. There is a short comment in the sml file that prompts you to add your code, but I am not quite sure how to/where to put other functions that I want to test in the main... Do you see what I mean. I really wish someone could show me a simple function being defined somewhere and used in the main(), like a factorial or something...

    Does that make sense? Do you see what I mean?

    Thanks,
    Emmi

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    OK, I don't know anything about SML, but I do know Visual Studio, so let's give this a try...

    I've created a new SML.NET Application Project named Project1 in Visual Studio. From Visual Studio's Solution Explorer, I open the file Project1.sml; it looks like this:
    Code:
    structure Project1
      : sig val main: string option array option -> unit
        end = 
    struct
        fun main  (a : string option array option) = 
            (*@TODO: add your code here *)
            ()
    end
    I change the file so that it looks like this:
    Code:
    structure Project1
      : sig val main: string option array option -> unit
        end = 
    struct
        fun main  (a : string option array option) = 
            print "Hello, world!\n";
    end
    Now I compile the code by selecting "Build Solution" from Visual Studio's Build menu. After the Output window tells me that it has built successfully, I select "Start Without Debugging" from Visual Studio's Debug menu. Voila!

    OK, let's add a factorial function:
    Code:
    fun fact n : int = 
        if n = 0 then 1 else n * fact(n - 1);
    Apparently we must define functions before they are called, so we'll insert this above our "fun main", then call it, telling it to calculate the factorial of 5 and printing the result:
    Code:
    structure Project1
      : sig val main: string option array option -> unit
        end = 
    struct
        fun fact n : int = 
    	if n = 0 then 1 else n * fact(n - 1);
    
        fun main  (a : string option array option) = 
    	print (Int.toString(fact 5) ^ "\n");
    end
    Same procedure as before: Build -> Build Solution (or Ctrl + Shift + B), then Debug -> Start Without Debugging (or Ctrl + F5).

    Pretty cool, huh? :-)
    Last edited by Phil Weber; 08-08-2007 at 03:53 AM.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Aug 2007
    Posts
    3

    Talking

    Phil,

    Thank you very much!

    I tried what you said and that works wonders. But there are weird things like what errors the following code generates:
    Code:
    structure Factorial
      : sig val main: string option array option -> unit
        end = 
    struct
    	
    	fun fact n : int = 
    	if n = 0 then 1 else n * fact(n - 1);
    
        fun main  (a : string option array option) = 
    		val toPrint = fact 5 : int;
    		print ("fact 5 = " ^ Int.toString(toPrint) ^ "\n");
    end
    I do not undestand quite well the error messages and I do not know why that assignment line does not work...

    I also tried this:
    Code:
    structure Factorial
      : sig val main: string option array option -> unit
        end = 
    struct
    	
    	fun fact n : int = 
    	if n = 0 then 1 else n * fact(n - 1);
    
        fun main  (a : string option array option) = 
    		print ("BEGIN EVAL\n");
    		print ("fact 5 = " ^ Int.toString(toPrint) ^ "\n");
    		print ("END EVAL\n");
    end
    And for some reason, that's not good either.

    Can you guide me through this a little bit more and also let me know how you figure out stuff? Do you have documentation or is it just experience? The document that you reference does not help me much, so...

Similar Threads

  1. Cannot start RMI Server
    By shaoen01 in forum Java
    Replies: 5
    Last Post: 09-16-2006, 09:42 PM
  2. Replies: 1
    Last Post: 12-09-2002, 01:57 PM
  3. Turn InStr(w, x, y, z) into InStr(w, x1, y1, vbBinaryCompare) ?
    By Joe \Nuke Me Xemu\ Foster in forum VB Classic
    Replies: 8
    Last Post: 12-21-2001, 07:21 PM
  4. SQL Server Agent wont auto start
    By David Hay in forum Database
    Replies: 2
    Last Post: 04-02-2001, 07:11 PM
  5. Re: MMSQ fails to start with errors in the Event Viewer
    By Paul Edwards in forum Enterprise
    Replies: 0
    Last Post: 09-19-2000, 12:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links