Parameters

PyScripter

Parameters
Previous Top 

Custom Parameters are implemented using ideas and code from the Syn Editor project (http:\\syn.sf.net). It is a very powerful feature allowing the developement of custom command line tools and facilitating autocompletion.


Parameter syntax
Parameter is any ParameterValue, that is enclosed by the parameter delimiters (currently "$[" and "]") e.g.

    $[ProgramFiles]

Predefined system parameters (variables, that can be replaced in the command
line, scripts, templates and in inserted text) are changed and extended. Now they include:

Python Paths
    Python32Dir              - Installation directory of Python version 3.2
    Python31Dir              - Installation directory of Python version 3.1
    Python30Dir              - Installation directory of Python version 3.0
    Python26Dir              - Installation directory of Python version 2.6
    Python25Dir              - Installation directory of Python version 2.5
    Python24Dir              - Installation directory of Python version 2.4
    Python23Dir              - Installation directory of Python version 2.3
    Python32Exe             - Executable of Python version 3.2
    Python31Exe             - Executable of Python version 3.1
    Python30Exe             - Executable of Python version 3.0
    Python26Exe             - Executable of Python version 2.6
    Python25Exe             - Executable of Python version 2.5
    Python24Exe             - Executable of Python version 2.4
    Python23Exe             - Executable of Python version 2.3
    PythonDir                  - Installation directory of active Python version
    PythonExe                 - Executable of active Python version
    PythonVersion           - Version of active Python

  Some parameters, that represent system folders for current configuration:
    ProgramFiles             - Program Files folder for current configuration
    CommonFiles            - Common Files folder for current configuration
    Windows                   - Windows folder for current configuration
    WindowsSystem        - Windows System folder for current configuration
    WindowsTemp          - Windows Temp folder for current configuration
    MyDocuments           - My Documents folder for current user configuration
    Desktop                     - Desktop folder for current user configuration

  Some parameters, that represent other system information:
    CurrentDir                 - Current Directory
    DateTime                  - Current date and time in the default short date-time format
    UserName                 - the name of the user currently logged onto the system
    Paste                        - returns contents of the clipboard
    CmdLineArgs            - returns the active command line arguments

  Some parameters, that represent PyScripter specific information:
    ActiveDoc                  - file name of the Active Document
    ActiveScript               - file name of the Script you are about to run/debug
    Project                      - file name of the Active Project
    OpenFiles                 - file names of all open files, separated with space
    ModFiles                   - file names of modified files, separated with space
    Exe                           - parameter, pointing to PyScripter executable file

  And some other useful:
    SelectFile                  - opens a FileOpen dialog for file selection
    SelectedFile              - returns the last selected file
    SelectDir                   - opens "Browse for folder" dialog for folder selection
    SelectedDir               - returns the last selected path


Custom parameter value can contain also other parameters and modifiers. They are calculated when the value is required, not when the parameter is loaded from file,  so they always points to the actual other parameter value. For example

    QuotedSelText=$[ActiveDoc-SelText-Quote]

will return quoted selected text of the active document

Parameter modifiers
We have also the so-called "Parameter modifiers" - Small words, that are placed after parameter, separated by '-' They actually represent one parameter
  functions, which modify value, returned from parameter. For the moment valid are:

    Path                   - extracts file path from filename (with '\' at the end)
    Dir                      - extracts file dir from filename (without '\' at the end)
    Name                  - extracts only file name
    Ext                      - extracts file extension
    ExtOnly               - extracts file extension without dot before it
    NoExt                  - returns full file name without extension
    Drive                   - extracts only file drive
    Full                     - expands file name to absolute file name
    UNC                   - expands file name to absolute UNC file name
    Long                   - returns long file name
    Short                   - returns short file  name
    Sep                     - adds '\' at the end, if there is no
    NoSep                - removes '\' from the end, if there is any
    Type                   - returns file type of the file, as shown in the explorer
    Text                    - returns file text
    EdText                - returns file text (but actual text from editor, if file is changed)
    CurWord             - returns current word of the given file, if is open in editor
    CurLine               - returns current line of the given file, if is open in editor
    CurLineNumber  - returns current line of the given file, if is open in editor
    SelText               - returns selected text in the given file, if is open in editor
    Select                 - selects text (modifier is valid only for "Insert test" tools)
    Env                     - returns environment variable (the parameter must contain its name)
    Reg                     - returns registry key value for given registry key name
    UpperCase         - converts parameter value to uppercase
    LowerCase         - converts parameter value to lowercase
    Quote                  - adds quotes to parameter value
    UnQuote             - removes quotes from parameter value
    Date                    - returns date portion from date time parameter
    Time                   - returns time portion from date time parameter
    FileDate              - returns file date
    DateCreate         - returns file creation date
    DateWrite           - returns file last write date
    DateAccess        - returns file last access date
    DateFormat        - formats date with given format (the prior modifier must contain desired format)

Parameter syntax is extended so you can type

            $[Parameter=DefaultValue]

which means, that if this Parameter is not found, Default Value will be used.

            $[Parameter?Question]

will open a Input Box and ask with 'Question' for a value of Parameter.

            $[Parameter=DefaultValue?Question]

will open a Input Box and ask with 'Question' for a value of Parameter, but if there is no value, will offer DefaultValue as default.

            $['Some value']

is returned as it is (only parameters in SomeValue are replaced with their values) - this is useful, if you want to pass specific value to modifier -for example

            $['31.01.2002'-'YYYY/MM/DD'-DateFormat]

will return you 2002.01.31

ParameterValue can be conditional parameter. Format is

            $[(ParameterCondition)TrueValue:FalseValue]

where TrueValue and FalseValue are any valid ParameterValue. Symbol ':' is not required - if it is missing, its assumed that this means empty FalseValue. ParameterCondition can contain one or two ParameterValues and one of operations "=", "<>", "<", ">", "<=", ">=", "IS NULL" or "IS NOT NULL" or text to be asked in dialog (in single quotes) and "?" (question mark symbol) after it. In this case value will depend from the user input.
                                                                                                
            Condition1=$[($[Project] IS NULL)'There is no project open':'Project file is $[Project]']
            Condition2=$[('Answer Yes or No'?)'Your answer was Yes':'Your answer was No']

Parameters can be placed AutoComplete items and Tools too.

Editor Shortcuts
You can use parameters in the IDE editor, the external tool configuration dialog and the Code Template definition.  To facilitate the entry of parameters and modifiers PyScripter provides parameter and modifier completion (selection from a pop-up list) using the following shortcuts.

·    Shft+Ctrl+P provides Parameter completion
·    Shft+Ctrl+M provides Modifier completion
·    Shft+Ctrl+R replaces all parameters with their values


LIST OF DEFINED PARAMETERS AND MODIFIERS

These are all parameters and their values at the moment of writing of this
file.If you want to see their values, copy the following into an editor and select "Replace parameters" from "Edit menu"

System parameters:
CurrentDir=$[CurrentDir]
ProgramFiles=$[ProgramFiles]
CommonFiles=$[CommonFiles]
Windows=$[Windows]
WindowsSystem=$[WindowsSystem]
WindowsTemp=$[WindowsTemp]
MyDocuments=$[MyDocuments]
Desktop=$[Desktop]
Exe=$[Exe]
ActiveDoc=$[ActiveDoc]
ActiveScript=$[ActiveScript]
Project=$[Project]
ModFiles=$[ModFiles]
DateTime=$[DateTime]
UserName=$[UserName]
SelectFile=$[SelectFile]
SelectedFile=$[SelectedFile]
SelectDir=$[SelectDir]
SelectedDir=$[SelectedDir]
Paste=$[Paste]
OpenFiles=$[OpenFiles]

ParameterModifiers:
ActiveDoc-CurLine=$[ActiveDoc-CurLine]
ActiveDoc-CurWord=$[ActiveDoc-CurWord]
ActiveDoc-SelText=$[ActiveDoc-SelText]
'PATH'-Env=$['PATH'-Env]
PYTHON24DIR=$['HKLM\SOFTWARE\Python\PythonCore\2.4\InstallPath\'-Reg]
'0'-Param=$['0'-Param]
Exe-DateAccess=$[Exe-DateAccess]
Exe-DateCreate=$[Exe-DateCreate]
Exe-DateWrite=$[Exe-DateWrite]
Exe-FileDate=$[Exe-FileDate]
Exe-FileDate-'DD/MM/YYYY HH:NN:SS'-DateFormat=$[Exe-FileDate-'DD/MM/YYYY HH:NN:SS'-DateFormat]
Exe-FileDate-Date=$[Exe-FileDate-Date]
Exe-FileDate-Time=$[Exe-FileDate-Time]
Exe-Dir=$[Exe-Dir]
Exe-Dir-Sep=$[Exe-Dir-Sep]
Exe-Path=$[Exe-Path]
Exe-Path-NoSep=$[Exe-Path-NoSep]
Exe-Drive=$[Exe-Drive]
Exe-Ext=$[Exe-Ext]
Exe-Full=$[Exe-Full]
Exe-Long=$[Exe-Long]
Exe-LowerCase=$[Exe-LowerCase]
Exe-Name=$[Exe-Name]
Exe-NoExt=$[Exe-NoExt]
Exe-Quote=$[Exe-Quote]
Exe-Short=$[Exe-Short]
Exe-Type=$[Exe-Type]
Exe-UNC=$[Exe-UNC]
Exe-UpperCase=$[Exe-UpperCase]

Day=$[DateTime-'DD'-DateFormat]
Month=$[DateTime-'MM'-DateFormat]
Year=$[DateTime-'YYYY'-DateFormat]
Hour=$[DateTime-'HH'-DateFormat]
Minutes=$[DateTime-'NN'-DateFormat]
Seconds=$[DateTime-'SS'-DateFormat]


Defining your own custom parameters

You can define your own custom parameters by selecting the "Custom Parameters..." menu command under Tools|Options.  The Custom Parameters dialog is displayed below:

graphic