Geeks With Blogs
Code.Blog Code Talk for the Game Developer
Hooray!  I have a GeeksWithBlogs blog!  Welcome to my blog which will focus on my ramblings and posts related to game and application development.  I'm just getting into my Exploring Technology class (boo!) but I should update later with some code snippets and such.

Update:  Well class isn't over but I'm bored so I'll post some code I figured out last night:

    let opSaveFile sender args =
        if (documentList.Item(lstProject.SelectedIndex).isNew = true) then
            let ofdDialog = new SaveFileDialog(Filter = "SCompiler Files (*.scpt)|*.scpt|All Types|*.*", Title = "Save Script As...") in
            if ofdDialog.ShowDialog() = DialogResult.OK then begin
                match ofdDialog.OpenFile() with
                | null -> txtLog.AppendText("File Save Failed")
                | stream ->
                    let r = new StreamWriter(stream) in
                    prevSelection <- lstProject.SelectedIndex;                   
                    documentList.Add({fullpath=ofdDialog.FileName; filename=ofdDialog.FileName.Remove(0, ofdDialog.FileName.LastIndexOf("\\") + 1); text=txtEditor.Text; isNew=false;});
                    lstProject.SelectedIndex <- documentList.Count - 1;
                    txtLog.AppendText("\nFile Saved: " + documentList.Item(lstProject.SelectedIndex).filename);
            let r = new StreamWriter(documentList.Item(lstProject.SelectedIndex).fullpath) in
            txtLog.AppendText("\nFile Saved: " + documentList.Item(lstProject.SelectedIndex).filename);

Notice the begin and end bolded parts.  Without those the else wants to attach itself with that first if, sort of acting like a { } in C++ and C#.  Anyways, seems like something really simple but in F# you don't really use 'end if' style items so you need to block off your if sections with ( ) or begin end. Posted on Monday, April 7, 2008 9:04 AM | Back to top

Comments on this post: First Blog Post

# re: First Blog Post
Requesting Gravatar...
Welcome to the GWB community. Looking forward to what you've got to say!
Left by Jerod Crump on Apr 07, 2008 10:34 AM

Your comment:
 (will show your gravatar)

Copyright © Matthew Christian | Powered by: