text stringlengths 0 897 |
|---|
- Be sure you've used the correct capitalization. Remember that MiniScript is case-sensitive. So check for places you may have typed `RollTotal` or `rolltotal` rather than `rollTotal`, for example. |
- Check that every `if` statement has a `then`, and unless it's a single-line `if`, it should also have a matching `end if` statement. |
- Check that every `while` has a matching `end while`. |
- Be sure every open parenthesis `(` has a matching close parenthesis `)`. |
- Make sure your quotation marks are balanced. Every string must have quotation marks at the beginning, and quotation marks at the end. |
- Some text editors may try to apply "smart quotes," that is, quotation marks that curl towards the text they enclose. Those will not work with MiniScript (or any other programming language I've used). You need to use the straight kind, like `"`. If you're running into this problem, find the option to turn off smart... |
- Make sure any tests for equality are using two equal signs, `==` instead of `=`. If you get an error like "got OpAssign where Keyword(then) is required", you made this mistake (and now you know how to fix it). |
- The Bit-Flip Game uses some square brackets on lines 26 and 27, to get to the first and second characters of the player's input. Double-check that you're using square brackets and parentheses exactly as shown. |
{pageBreak} |
A> **Chapter Review** |
A> - You entered and debugged several real programs that do interesting things. |
A> - You practiced using variables, assignment, `if` blocks, and `while` loops. |
A> - You exercised your coding muscles, laying down brain pathways through which magic will one day flow. Savor this accomplishment. You are well on your way! |
{chapterHead: "Day 8: Command-Line MiniScript", startingPageNum:75} |
{width: "50%"} |
 |
Q> Ah, the command line. This is the interface of a Programmer. |
Q> Not as clumsy or random as a GUI... |
Q> An elegant interface for a more civilized age. |
Q>— Obi-wan Codonly |
A> **Chapter Objectives** |
A> - Install command-line MiniScript on your computer. |
A> - Learn about a Read-Eval-Print Loop, and how it makes coding even more fun and interactive. |
A> - Learn how to represent and work with a list of data. |
A> - Realize that a programming language may be used in different environments, but your knowledge still applies. |
For many readers, all code written this point has been run in the MiniScript *Try-It!* web page. However, that is only one way to run MiniScript code; there are many others. |
In the beginning it is very easy to confuse the *programming language* with the *development environment* you are using. |
programming language |
: A formal language used to specify a computer program, e.g., MiniScript |
development environment |
: A software application that provides a programming language and related tools, such as a code editor and libraries of extra intrinsic functions. E.g., the Try-It! web page, command-line MiniScript, and Mini Micro |
The great thing is, your knowledge of the language from one environment applies equally well in other environments. Yet each one provides unique new capabilities. Today you're going to add a second MiniScript environment to your tool set. |
## Command-Line MiniScript |
{i: "MiniScript, command-line;command-line MiniScript"} |
Today's computers use a graphical user interface (GUI) of buttons, menus, and other widgets, manipulated more with a mouse or touch screen than by typing. However, on desktop computers at least, there is still a command line available to power users such as yourself. |
command line |
: a user interface based around typing commands and getting interactive results |
To someone raised on a GUI, the command line might seem old-fashioned. But there are many power users today who rely on it heavily. With practice, complex operations can be carried out efficiently with a command line that would take much longer (or in some cases be impossible to do at all) with pointing and clicking.... |
Unfortunately, the details of how to find and use the command line are a bit different depending on what kind of computer you use. We'll cover here the three main varieties of desktop platforms: Windows, Mac OS, and Linux. |
{pageBreak} |
### Windows |
On a Windows computer, the standard command line is called `cmd` (short for "Command Prompt"). The easiest way to get to it is probably: (1) click on `Start` in the lower-left corner of your screen; (2) type `cmd` and press Enter. |
If you type "Windows command line" or "how to use Windows cmd" into your favorite web search engine, you will probably find some great introductory resources. The main commands you should pay attention to are `dir` (directory, i.e. list files for the folder you are in) and `cd` (change directory, i.e. move to a differ... |
Once you have mastered those, you are ready to download and use command-line MiniScript. Point your web browser to <https://miniscript.org/cmdline/>, and click the link for "miniscript-win.zip". This should download the zip archive, probably into your Downloads folder. Find that file in Windows Explorer, select it, ... |
Now go back to Command Prompt, navigate to that directory using the "cd" command, and run miniscript by typing `miniscript.exe` and pressing Enter. If all goes well, you should see the word "MiniScript" followed by some version information, and a ">" prompt, as shown in the image below. |
{width:"75%"} |
 |
Chances are good, however, that all will *not* go well, and Windows will instead decide that MiniScript is a "threat" (because it can execute commands), and quarantine the file, removing it from the folder where you had it and tucking it away in some hidden location. The exact steps you follow to fix this may vary sli... |
1. Open **Windows Security** (again from the Start menu). |
2. Click on **Virus & threat protection**, and then on **Protection history** (or **Threat history**). |
3. In the filter pop-up, select **Quarantined items**. |
4. Click miniscript.exe, and then click **Restore**. |
This should both restore the file, and tell Windows that this particular file is OK and not actually a threat. |
Once you've done all that, you should be able to run `miniscript.exe`, and get a result like the above. Once you see that MiniScript header and version info, you're ready to go! |
Finally, it should be noted that there are alternatives to the built-in Command Line app for Windows. Terminal is a popular one, as is the somewhat older PowerShell; both are from Microsoft and available in the Microsoft Store. If you're already using one of these alternatives, feel free to continue using it with Min... |
### MacOS |
The procedure on a Mac is similar to on Windows. The app you'll want to use is called Terminal, and can be launched via Spotlight, or directly from Applications/Utilities. If you're new to Terminal, do a search for "mac useful terminal commands," and read an article or two. There are plenty of good resources on this... |
Now you're ready to download and use command-line MiniScript. Point your web browser to <https://miniscript.org/cmdline/>, and click the link for "miniscript-mac.zip". This should download the zip archive, probably into your Downloads folder. Find that file in Finder, and double-click it to unzip. This should resul... |
At this point, chances are Finder is going to get cranky, with a message along the lines of "MiniScript can't be opened because it is from an unidentified developer." If that happens, click OK to dismiss the alert, then right-click MiniScript and choose "Open" from the contextual menu. You'll get a similar alert, but... |
The result should look similar to the image below. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.