C
C#8mo ago
rapid

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
rapid
rapid8mo ago
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.
Thinker
Thinker8mo ago
every time I open a file
How do you want this to work? Inside Visual Studio?
rapid
rapid8mo ago
is it possible for me to just open a .baobi from my desktop and have the script run?
Thinker
Thinker8mo ago
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.
rapid
rapid8mo ago
perfect!! and how..?
canton7
canton78mo ago
(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]
rapid
rapid8mo ago
how do i get the .exe file of a visual studio console app?
canton7
canton78mo ago
It'll be in bin/?
rapid
rapid8mo ago
oh
Thinker
Thinker8mo ago
Or you could publish it as a single file, if you want to distribute it
rapid
rapid8mo ago
yes!! but how do read the .baobi file
canton7
canton78mo ago
The 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 string
rapid
rapid8mo ago
great! ill do all of this when i get home, thanks for the help!
Want results from more Discord servers?
Add your server
More Posts
ASP.NET Core 8 Web API, can't use additional fields with Identity registrationHello, It's my first time using Identity, so I came across some issues. When I input json data neceusing serilog (c#) in a vb.netHello, I have an old application which is written in vb.net. I'm searching for a sollution to use s✅ Why is a variable false in project in WPF .Net application even after it should be true?Hi I'm currently building my first C# project and could really need some help, I'm supposed to take i need help because i dont why this is nullif u need smt (sql or smt ab my visual code lmk please)Is there a way to ensure a function can't modify a parameter?I often want to pass objects or values into a function, and make sure the function cannot change it.why is my handler not working, also the breakpoint doesn't even get hit for it[ValidateAntiForgeryToken] public IActionResult OnPostPlaceOrder() { tryWinForms Course Registration/Validation HomeworkI just started my C# class for college and I've been having a real tough time trying to get my WinFo✅ Trying to split a string in a file using commasI have a string in a file with a bunch on commas which im trying to make into an array by splitting More efficient or performant way of serializing permission nodes?As a personal project, I'm designing a chat platform similar to Discord. Discord's permission systemOutputting the files from a folder and then numbering themSo ive been able to output files from a folder but now i want to number them 1 to 12 but im not sure