how to run this code in VS F# Interactive?

Answered how to run this code in VS F# Interactive?

  • Wednesday, August 01, 2012 12:01 AM
     
      Has Code

    hi,

    how to run this code in VS F# Interactive?

    when i send it to F# interactive using Alt+Enter no things happened.

    open System
    let mutable names : string[] = Array.empty
    let mutable continue1 = true
    while continue1 do
    
        Array.Resize(&names,names.Length + 1)
        printf "Please enter name %d: " names.Length
        let name = Console.ReadLine()
        names.[names.Length - 1] <- name  
                  
        printf "do you want to get more names?(y or n)"
        let answer = Console.ReadLine()
    
        if answer <> "y" then
            continue1 <- false
            printfn "\nArray Elements: %A" names
        printfn ""

All Replies

  • Wednesday, August 01, 2012 6:21 AM
     
     

    <del>You need to tell FSI that you've finished this code fragment by typing two semicolons and then hitting Return.</del>

    <del>It works quite happily when you do that.</del>

    My bad , not reading the question in detail, but just pasting the code into the F# interactive console I always have open when reading the forum.

    • Edited by Mr. Tines Thursday, August 02, 2012 6:33 PM
    • Edited by Mr. Tines Thursday, August 02, 2012 6:34 PM
    •  
  • Wednesday, August 01, 2012 10:53 AM
     
     Answered

    You don't need to terminate with ";;" when using Alt-Enter from Visual Studio.

    I think it is the use of ReadLine(), see http://stackoverflow.com/questions/8022512/how-to-read-user-input-using-f-interactive-in-visual-studio

    • Marked As Answer by Rainmater Wednesday, August 01, 2012 7:51 PM
    • Unmarked As Answer by Rainmater Thursday, August 02, 2012 8:48 PM
    • Marked As Answer by Rainmater Thursday, August 02, 2012 8:50 PM
    •  
  • Wednesday, August 01, 2012 7:56 PM
     
     

    thanks,

    this problem is exist in new version of VS (2012 RC) still.

    is a better graphical UI for F# interactive? 


    • Edited by Rainmater Thursday, August 02, 2012 8:56 PM
    •