Reputation: 55
I am making a coding language, I'm done making it now, but how do I make it like in a command prompt, and your file where you have your code inside, is called "code.scriptex", that you can type: scriptex code.scriptex
?
What I mean with a command prompt: image
I've searched it up, but nothing came up, so I came here on stackoverflow to ask it!
Code of language (It's just Python lmao):
file = input()
pro = open(file,"r").read()
try:
exec(pro)
except Exception as err:
print(err)
I expect it to run my python file and make it work inside the command prompt. I will edit my question if something isn't clear.
Upvotes: 0
Views: 1465
Reputation: 1850
Not sure, but i believe what you are trying to ask is, How to create a recognizable command in Command Prompt (CMD).
For that you have to specify the directory which contains the files (.exe
for the most part) which you want to make as command in the Environment Variable:-
A Menu will pop up, from there select Environment Variable
Option
Another Menu will show up, there will be a section named System Variables
in the new popup, it will contain a attribute named path
in it, you have to edit that variable path by either double clicking
it, or selecting path attribute and selecting edit
option
Edit Environment Variable
will show up, from there select the new option
scriptex.exe
/scriptex.py
file exists)WHAT WE DID:-
We specified path to our specific directory, in Environment variable. Now we are able to access any file, inside that directory in an abstract way (without referencing its whole path).
EXAMPLE:-
This is the Directory which I added in the Environment variable path, now It allows me to access any file inside this folder, without specifying its full path. (You can see my CWD is different from the directory in which my .exe
is, but still i am able to execute the file)
Upvotes: 1