Making an interpreter read custom filename extensions
I made an interpreter in Visual Studio (C#) for my own language. My question is, how do I make it so the interpreter runs every time I open a file with .baobi as the filename extension?
13 Replies
Basically, I need the contents of the file to be assigned to a string in my interpreter script called "code" and then let the script do its thing.
PS: I am relatively new to C#, so sorry for articulating some sentences weirdly.
every time I open a fileHow do you want this to work? Inside Visual Studio?
is it possible for me to just open a .baobi from my desktop and have the script run?
Yes, you can use file associations to set what program opens files with certain file extensions.
You could for instance set the extension
.baobi
to open with a console app you've made which runs your interpreter.perfect!!
and how..?
(Those are a Windows thing, and they're set up in the registry. Or you can right-click, Open With)
Then if you select "Choose another app", you can browse to your exe and click "always"
Your exe will be launched, and the path to the file will be passed as
args[0]
how do i get the .exe file of a visual studio console app?
It'll be in bin/?
oh
Or you could publish it as a single file, if you want to distribute it
yes!!
but how do read the
.baobi
fileThe path to the .baobi file is passed as
args[0]
in your Main
method
You can then read it with any of the File I/O methods. File.ReadAllText
will read the entire file into a stringgreat! ill do all of this when i get home, thanks for the help!