Loading your own scripts into tryfsharp.org

Today I'm glad to mention to the F# community an important feature of the Try F# web app.  www.tryfsharp.org has the ability to take a query parameter specifying a web accessible script.

To see what this can do for you, I encourage you to take a look at the latest on the F# snippet site. In particular, look for the "tryfsharp.org" button on each snippet page:

This links to a URL which instructs tryfsharp.org to load the raw text of the snippet into the browser application. A typical URL is like this:


Try F# will then ask you if you want to load this script, and then you can press the "Run" button in Try F# to execute the script. You can also evaluate individual parts of the script yourself - you will often have to do this for snippets from the F# snippet site. 

Here is an example of this integration: http://fssnip.net/2Y. Once on the F# snippet site, click the tryfsharp.org button to load the code in Try F#, and then "run" to run the snippet. Be aware that not every snippet will be appropriate for the browser. Some snippets may not run in Try F# if they rely on features not available in the Silverlight environment. 

One technical detail: Besides modifying the web page layout on his site, Tomas Petricek also had to include a policy to allow cross-site access from the Try F# Silverlight application - you can see a sample of this file here: http://www.fssnip.net/clientaccesspolicy.xml. You will also have to do this for sites containing new static content that you want loaded into Try F#.



p.s. You will notice that each time you try a snippet, you have to initialize the Silverlight application which takes a little time. An alternative would be to arrange all snippets into a loadable script so they can be loaded like the very last sample on the TryF# website tutorial, which loads a full set of samples into the canvas window.


Comments (0)

Skip to main content