How do you get exact path to My Documents using F# - f#

Is there any way to get My Documents path in F#?
I found Environment.SpecialFolder, but it looks like it is only used in C#.

I'm not sure what you mean by "it looks like it is only used in C#". The exact same invocation you'd use in C# actually works in F# as well:
open System;
let myDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

Related

How to create "list of type" for HtmlProvider<list of HTML files> in F#?

I am very new to F# and trying to convert my python script to F# code for my learning.
i want to parse multiple (around 25 files) static html files to extract similar information from each file.
I want to have a list of file handle for all the html files.
I am able to do it for single file as:
type SummaryHtmlType = HtmlProvider< #"C:/MyLocation/Summary_1.html">
I tried something similar to XmlProvider (even not sure if that's correct for XmlProvider), but no success.
type MyType = HtmlProvider<htmlFileList; SampleIsList=true>
Let me know solution even if there is all together different approach to do it.
"C:/MyLocation/Summary_1.html" in type SummaryHtmlType = HtmlProvider< #"C:/MyLocation/Summary_1.html"> is a sample file for HtmlProvider get the basic structure.
To parse file or url, use Load method like SummaryHtmlType.Load(url)
For more information, see http://fsharp.github.io/FSharp.Data/library/HtmlProvider.html

Using signature file in script

I like using .fsi signature files to control visibility. However, if I have both Foo.fsi and Foo.fs files in my solution, and #load "Foo.fs" in a script, it doesn't seem like the corresponding signature file gets used. If I do:
#load "Foo.fsi"
#load "Foo.fs"
... then the desired visibility control happens. Is this the recommended way to achieve this, or is there a better way to do it? In a perfect world, one would like to see the signature file automatically loaded, too.
Not a final answer, but a better way.
From reading Expert F# 4.0 one can do
#load "Foo.fsi" "Foo.fs" "Foo.fsx"
All three loads are on one line.
TL;DR
The link to the book is via WolrdCat just put in a zip code and it will show you locations near there where the book can be found.

XQuery: How to get system path separator?

I would like to know if there is a possibility to get the system path separator inside my XQuery code without special libraries?
No. There's nothing defined in the XQuery 1.0 or XQuery 3.0 specs to identify details of the filesystem.
However, using fn:doc(), you should be able to reference filesystem URIs generally by preceding the file name with file:/// and using / as a separator for directory.
As already mentioned, I don't think it is possible to achieve this by using standard XQuery functionality. However, depending on what processor you are using, it is quite likely that you can use Java bindings. I am aware that at least BaseX, eXist and Saxon support this.
By using this technique you can get the separator
declare namespace system="java:java.lang.System";
system:getProperty("file.separator")
Or if your processor supports the expanded QName notation you can also write
Q{java:java.lang.System}getProperty("file.separator")

Properties.Resources.XXXX Namespace or Module not Defined

I'm trying to read in the text (as a string) of an XML file from my Resources. The XML file is named MyXMLResourceFile.resx.
I tried using the C# way using
let myFile : string = Properties.Resources.MyXMLResourceFile
but it is giving me the error (under Properties):
The namespace or module 'Properties' is not defined.
I'm assuming I'm missing an open but have no idea what it would be.
Sorry, I'm still pretty new to F# coming from VB.
Additional information:
I made the resx file myself per this SO answer I then looked to see how others accessed it. In C# they did Properties.Resources.XXXX per this project I saw you could use ResourceManager but didn't see any method to read the whole file directly into a string.
The namespace or module 'Properties' is not defined.
That's because the namespace Properties is not defined. You probably brought the resx file from another project. Open the associated .Designer file, if it doesn't appear in the F# project, open it up in the original project. You will see a namespace with and a bunch of C# code, assuming the original project was in C#. The namespace of this file has to be the same namespace of the project where you are trying to call it.
But, since this is C# code, it won't run on a F# project. You have two choices: use a code generator to generate the associated .Designer class in F# code with the Properties namespace, (I don't know if such generator exists); or pre-compile the resx in the original project and reference it as a dll from your F# project, then you can access it with ResourceManager.

ZF2 BBCode Parser

Hiho,
I use the ckeditor on my website for special textareas like forum
or signatures.
But I have a problem with the output. I use ZF2 and would like to
use ZendMarkup to render the output bbcode back in html.
But at every time I call
$bbcode->render(...)
I got the error
There is no Zend_Markup_Root markup.
The ZendMarkup is an extension inspired by the Zend_Markup from ZF1.
But I can't find any thing on API or other guides.
Does someone has any idea what as the problem is?
The ZendMarkup library is very old (last update is 10 months ago!) so I wouldn't use such library. If you would like, I think I traced the error down.
On this line there is a reference to Zend_Markup_Root while that should be ZendMarkup\Renderer\Markup\Html\Root. Try to change that line and see what happens.
Another way is to replace the ZendMarkup library with another library which does work and is updated regularly. An example is Decoda. If you load mjohnson/decoda in your composer.json, you can use Decoda in your Zend Framework 2 application:
<?php
use Decoda\Decoda;
$parser = new Decoda($bbcode);
$html = $parser->parse();
With tools like composer, there is no need to use solely Zend* components when there are better alternatives.

Resources