Appendix

Introduction

The appendix is not restricted to Pascal. It contains general advice and suggestions as well as overviews of topics such as networking that are demonstrated by many programs and tutorial sections on the site. This is only the start of what might turn out to be a large section, and we invite suggestions from students for topics and tips to include. We begin with a few very general tips.

  • Save work in at least two independent locations. (By Sod's Law your best work will, like some fine code we have been shown, be lost forever).
  • Although spaces are allowed in filenames and folder names, they cause problems with some software. (Even the Command Prompt in Windows 8.1 the command C:\Program Files\Internet Explorer\iexplore.exe fails and quotes are required for success in opening IE: "C:\Program Files\Internet Explorer\iexplore.exe".
  • Learning a few keyboard shortcuts can save you a lot of time over the years. We provide examples below.
  • Note our testing tips.

Windows Keyboard Shortcuts

See Microsoft Support for documentation of shortcuts. We list some particularly useful examples here.

  • Windows Logo+X: Menu of useful options accessed by typing a second letter such as
    • c: Command Prompt
    • p: Control Panel
    • t: Task Manager
  • SHIFT+DELETE: Delete item permanently
  • Windows Logo+D: Desktop with windows minimised
  • Windows Logo+E: Windows Explorer
  • Windows Logo+F: Find files or folders
  • Windows Logo+L: Lock the computer

Shortcut Key Combinations in Editors

These shortcuts work in many editors (with some exceptions noted) such as Notepad, Notepad++ and the text editors within Visual Studio, Lazarus and IDLE (for Python):

CTRL+N: New file
CTRL+O: Open
CTRL+S: Save

CTRL+A: Select all
CTRL+C: Copy
CTRL+V: Paste
CTRL+Z: Undo
CTRL+Y: Redo (but not in IDLE and it deletes current line in Lazarus!)
CTRL+SHIFT+Z in IDLE and Lazarus: Redo

CTRL+F: Find
CTRL+H: Replace
F3: Find next
SHIFT+F3 Find previous (behaves like F3 in IDLE)

CTRL+G: Go to line number (ALT+G in IDLE)
CTRL+Home: Go to start of document
CTRL+End: Go to end of document

Using Command Prompts

See equivalent commands in DOS (within Windows) and Linux.

You can perform many tasks more efficiently from the Windows Command Prompt. To copy text in quick edit mode simply select the text then press Enter or right-click. To paste from the clipboard, position the cursor over the Command Prompt window then right-click. To enable quick edit mode select the menu item properties then the Options tab and check the QuickEdit Mode checkbox.

Use the up and down arrow keys to navigate through the commands you have used in the session, but if you close the Windows command prompt it will lose its memory of the commands. (It is too easy to close the prompt subconsciously when you have finished with it temporarily!)

It is usually most convenient to change directory to a certain folder (e.g. by typing cd C:\Working) so that you do not need to prepend each filename with its path. Keep in a text file commands that are long and/or difficult to remember so that you can copy them and paste at the command prompt.

To change drive just type for example G: (omitting cd).

To emphasise the need to be confident with command prompts in these days of attractive user interfaces, we list some examples of the use of command prompts described on this website:

Commands at the Cygwin prompt
Installing programs on the Raspberry Pi
Arch Linux commands
Getting Started with the Pi's GPIO Port
Installing Firebird
Creating a Firebird Database
NuGet Package Manager prompt
Getting Started with Oxygene for Java
Automated Testing and Conditional Compilation

Syntax-Highlighting Your Code

Your code is easier to read and more impressive with syntax highlighting. Plugins are available for many editors.

In Notepad++, select menu item Plugins > NppExport > Export to RTF or Plugins > NppExport > Export to HTML.

You may want to customise the highlighting styles. In Notepad++ select menu item Settings > Style Configurator... and then select your language. You have many themes to choose from the drop-down list at the top of the Style Configurator, and can also change the colour of individual items such as a comment or keyword. If you want to add a new keyword, select the language and KEYWORD and type the new word(s) into the "User-defined keywords" box as shown for the new JavaScript keyword yield.

Notepad++ Configurator

Notepad++ Configurator

You might like to use an online syntax highlighter.

Formatting Your Code

As with syntax highlighting, well-formatted code is easier to read. We use an indent of only two spaces so that deeply nested constructs usually fit onto a single line on the web page. You can format as you code or use a "pretty printer" afterwards. In Lazarus you can select menu option Source > JEDI Code Format > Current Editor Window (or use the convenient shortcut CTRL+D which also works in Visual Studio). You can customise the automatic formatting in Lazarus by selecting menu option Source > JEDI Code Format > Format Settings. Select Format File in the IDE Options window to see the filepath of the XML file of settings. You can change settings either by checking boxes within IDE Options or by editing the XML file directly.

Correct formatting is crucial in Python. Mistakes in your formatting may be result in error messages from the Python interpreter.

Browsers

Chrome is our favourite web browser overall. It is quick, reliable, good for copying and pasting code from web pages and has great tools for developers.

Safari is special in allowing you to see unsigned applets without any warnings.

Internet Explorer 11, unlike its immediate predecessor, is fine for our HTML5/JavaScript/CSS output from Smart Pascal.

Useful keyboard shortcuts include:
F12: Developer tools
CTRL+ H: Browsing history. In Internet Explorer pages visited are conveniently sorted by website.
CTRL+ +: Increase font size
CTRL+ -: Reduce font size

Tip for searching: include the second-level domain (SLD) of the website in a of a website without an inbuilt search facility. For example, a search for pp4s quicksort works well for our site. (We feel that our hand-crafted indexes such as General Pascal Index and Index of Pascal Routines are underused by visitors).

Web Technology

We draw your attention to two developer tools in Chrome (an example of a fine browser).

When coding in JavaScript, the console is invaluable for its error messages. It is also useful for displaying messages during testing.

You can type JavaScript code fragments directly into the console for testing. See the results of an interactive session below.

function greeting(){console.log('Hello World!'); return 0;} greeting();
Hello World!
0

function greeting(){
  console.log('Hello World!');
  return 0; }
greeting();

Hello World!
0

The interpreter is trying to evaluate expressions and if you do not provide it with a return value it gives you the error message "undefined".

In the second (multi-line) example we used SHIFT+Enter to begin a new line (following the documentation).

Usefully, you can use the up and down keys to navigate through previous commands. Also, you have intelligent code completion to help you to write acceptable code.

The first tab (Elements) in Developer Tools allows you to see which CSS styles pertain and which have been overridden. You can change the styles to examine their effects. Here we use a colour picker to change the background colour of the table header in our introduction to the Resources section. If we had preferred the new style we could have copied the CSS code to our file jksdefault.css.

Colour Picker

Colour Picker

See the documentation.

Programming - a skill for life!

Getting Started, Links and other resources