-
Notifications
You must be signed in to change notification settings - Fork 0
Making a Program for PyTerm
I'm opening up the opportunity to make programs for PyTerm. However, they will need to be in the "PyTerm standardized form" as a program. Here's the basics to making a program.
As PyTerm operates in a gigantic while not if, elif, else loop, you'll need to prefix your program like this:
elif cmd == "yourprogramname":
Where yourprogramname is your program name.
Next, you'll need a few required lines to your program, for unification. You'll need these 3 lines at the start of any program.
print("Launching program - YourProgramName - vXXX")
print("")
cmd = ""
In the first section, all you're doing is announcing your program, and version, printing some white space, and resetting the cmd variable.
Basic programs can be made in the normal way, except 1 line needs to be added to the end of the program. Add this:
continue
Before your program ends.
If you need to have an input prompt in your program, your input must comply with PyTerm Input Unification.
Let's say my program name is "example", and I have an input in my program, and this is what my code looks like:
example_input = input("This is an input!")
Our input would change slightly. Here's the syntax for our input line, so far.
example_input-userinput...
The example_input pretty much equals what variable the user's input would be stored in.
If my user was to input something into the variable super_input, the start of my syntax would be:
super_input-userinput...
userinput is static, and doesn't change. All that indicates is that it's a user input.
Next, let's keep going. Let's add an @ sign after "example_input-userinput". Our syntax now looks like:
example_input-userinput@...
The next part will depend on what your program name is called. Let's say our program is called "inputtest". Here's what our syntax would now look like:
example_input-userinput@inputtest-prgm-"...
In the example, inputtest is our program name, and "-prgm" is static, and doesn't change.
Lastly, we need to add the prompt version. This is made really easy, and can be added with a variable. Our syntax should now look like:
example_input-userinput@inputtest-prgm-" + promptver2
Now, let's add on the input() and variable name, and we get this as our input:
example_input = input("example_input-userinput@inputtest-prgm-" + promptver2)
We can also automatically lowercase or uppercase the variable being entered, for case insensitivity.
Adding .lower() to the end of our input syntax will automatically lowercase our input. Adding .upper() will automatically uppercase our input, making it all caps.
Here's what the input line would look like with lower/upper added to the line.
example_input = input("example_input-userinput@inputtest-prgm-" + promptver2).lower()
example_input = input("example_input-userinput@inputtest-prgm-" + promptver2).upper()
As an example, let's say our user entered "tEsT" as an input. Here's what lower() and upper() would do.
lower() = test upper() = TEST
As a quick note, your variables for inputs need to prefix with your program name, to avoid incompatibility. If I had an input called "yay" in my program, and my program name was called "myawesomegame", the input variable would instead be called "myawesomegame_yay".
You are free to define functions in your program, you just need to prefix your function with your program name.
Let's say I have a program called "functest", and a function called "afunc", containing this:
def afunc:
print("Test")
Your function would now be called functest_afunc. functest represents the program name, while afunc represents what your original variable name is. Now, our code would look like this:
def functest_afunc:
print("Test")