0% found this document useful (0 votes)
260 views8 pages

How To Customize PSPad For MX PDF

This document describes how to customize the PSPad text editor for use with MX modeling software. It covers adding templates, syntax highlighting, clip definitions, and scripts. Templates, syntax files, clip files, and scripts need to be copied to specific folders for PSPad to recognize them for MX files. The customization allows for features like auto-formatting text, code navigation, and running models directly from the editor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
260 views8 pages

How To Customize PSPad For MX PDF

This document describes how to customize the PSPad text editor for use with MX modeling software. It covers adding templates, syntax highlighting, clip definitions, and scripts. Templates, syntax files, clip files, and scripts need to be copied to specific folders for PSPad to recognize them for MX files. The customization allows for features like auto-formatting text, code navigation, and running models directly from the editor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

How to customize the PSPad Editor for MX

This document is based on PSPad 4.5.5 (Build 2357).


PSPad Freeware Editor (http://www.pspad.com/) © 1991-2009 Jan Fiala.

The customization covers the following 4 areas:


1. Templates
2. Syntax Highlighting
3. Clip Definitions
4. Scripts / Macros

Templates
You can specify one or more templates for your MX Input Files.
If you create a new file in PSPad using the toolbar icon, and directly define that the new
file shall be a MX Input File, then the default template for MX Input Files will be used.

If you create a new file via “File > New file...”


you get a dialog where you can select a
template:

You can define different templates for


standard tasks, for example templates for
creating profile or cross-section drawings.

A template is a simple text file, which can contain as much text as you want.
The file must have the correct suffix and must be stored in the folder:
...\PSPad\Templates\

For MX for example: C:\Program Files\PSPad\Templates\Default.inp


You can specify in the settings (Settings > Program Settings...) that a new MX Input File
shall be created using the default template:

Syntax Highlighting
The Syntax Highlighting is controlled by the *.def file. This file stores the definition of the
MX Command Language, like the file filter (*.inp, *.pss, etc…) and the keywords (major
and minor options).
This file must be stored in the ...\PSPad\ Context\ folder.
For MX for example: C:\Program Files\PSPad\Context\MX Command Language.DEF

Clip Definitions
Clip Definitions are pieces of re-usable text which you can easily insert into your text files.
Clip Definitions are stored in *.INI files, where the filename must match the name of the
Syntax Highlighting file. Clip Definitions must be stored in the ...\PSPad\Syntax folder.
For MX for example: C:\Program Files\PSPad\Syntax\MX Command Language.INI

Scripts
PSPad provides scripting functionality (JScript and VBScript). You can write scripts to add
extra functionality to PSPad or to automate tasks.
I’ve written some VBScript functions which provide the following functionality:
I think most of these functions are pretty self-explaining. From bottom to top...:

• The Select... functions let you select a MX colour or a MX StyleSet or a MX macro


and will insert colour number or StyleSet name or macro name at the position of
the cursor.

• Run selected lines... will send those lines to MX which you currently select in your
MX input file – so it’s a bit like firing individual linemode options in MX (“View >
Linemode”), but more flexible since you have all the Editor functions available, can
simply select any part of an existing input file, can easily copy&paste...

• Run active input file... does precisely that – the currently active file is run in MX.
(you can also do that using the input file runner)

• Run all open files... will run all open files in the order of the file tabs from left to
right.
You can change the order of the tabs using drag and drop and thus change the
order in which the files are run.

• Run all project files... needs some explanations.


PSPad supports so called projects. Projects are a selection of files. You can
structure/organize files in virtual folders (to keep a better overview in the project
treeview – they can be saved in completely different folders on the harddisk). You
can change the order of files simply by dragging and dropping them in the
treeview. You can of course save those projects and open them again.
Run all project files... will run all files one after the other in MX, in the order from
top to bottom.
To show the projects toolbar: “View > Toolbars > Project”
To show the project treeview: use the left most icon on the projects toolbar, or
select “View > Tool Panel” or press Ctrl+F2
I haven’t defined keyboard shortcuts for those scripts yet, but even that is possible.

Installation instructions:

• Copy the “MX Command Language.DEF” file to the “...\PSPad\Context\” folder;


• Copy the “MX Command Language.INI” file to the “...\PSPad\Syntax\” folder;
• Copy the “Default.inp” file to the “...\PSPad\Template\” folder;
• Copy the “MXTools.vbs” file to the “...\PSPad\Script\VBScript\” folder;
• Copy the “PSPadMXAddIn.dll” file to the “...\PSPad\” folder;
• Copy the “RegisterMXAddInDLL.bat” file to the “...\PSPad\” folder – into the same
folder where the DLL is stored – and run it / double click it;

• (Re)Start PSPad;

• Select the menu items “Settings > Highlighter Settings”;


You now should have the entry “MX Command Language” in the “User Highlighters”
list.

• Select in the list on the left hand side the item “<not assigned>”, click on the tab
“Specification” and select “MX Command Language” in the User Highlighters list;
The word “<not assigned>” in the list on the left hand side now should have
changed to “MX Command Language”;
• You can select browse and select the Linemode help file (e.g. C:\Program
Files\Bentley\MX\MFW\xx_help\mxfnlinemode.chm) to get context sensitive help;

• Click on OK!

Set / change Syntax for an existing file


If you create a new file which isn’t an INP file, you can still make this file use the MX
syntax and user highlighting, using the “Change Syntax...” function.

You can call this function either from the toolbar...

... or from the menu (“View > Change Syntax...”)


Some comments regarding the syntax highlighting
1) The following file types are defined as MX Command Language files:
*.inp,*.txt,*.pss,*.mcm,*.log,*.prn,*.jou

2) PSPad doesn’t recognize three zeros or three spaces as start of a comment line.
Therefore “//” has been chosen as ‘comment style’, i.e. comment lines must start with “//”
for PSPad to recognise them as comment lines.
Examples:
000 PSPad doesn’t recognise this line as a comment line
This is also not recognised as a comment line.
// but this line is recognised – shown in green by default
000// this too is a comment line

3) The Code Explorer (Tools > Code Explorer) allows you to navigate fast thru your text
file – if you use certain tags/anchors in your input file (see screenshot on the next page).
The code explorer lists all anchors which you add. Clicking on an anchor in the code
explorer will take you that position in the text.

4) Case Sensitive Keywords


This is checked so that you can avoid getting highlighting in areas where you don’t want
any highlighting. You should use all uppercase characters for the major options and other
keywords, and capitalized or all lowercase characters for model names and string names
(see screenshot on the next page).
Example with syntax highlighting, anchors and the Code Explorer:

To insert templates or “clips” into your input file you simply need to press CTRL + Space
(or go to Tools > Show Clips). This will show a list with all the clips in the clip definition
file. The list will be filtered when entering some characters. Following screenshot shows all
minor options in the clip definition file which start with “10”.

You might also like