Ide/External Tools

From wiki.visual-prolog.com

Revision as of 12:52, 4 April 2013 by GalinaTchekmareva (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

IDE

How to Add Calls of Other Applications

The Tools | Configure Tools command opens the Tools dialog. In this dialog you can assign 10 commands that will be executed when you pressing the hot keys from Ctrl+1 till Ctrl+0. These commands can be executed onto a file opened in any having focus IDE editor (in the IDE text editor and in the IDE resource editors).

How to Invoke a Command

For example, you can assign to the hot key Ctrl+3 a command line, which will invoke a command to switch off read only attribute from a file opened in the having focus IDE text editor. To do this one should select in the Tools dialog the line with Ctrl+3 hotkey, type in into the Command Line field a command line that should be executed on pressing the Ctrl+3 hot key. (Otherwise, you can find a file to be executed using the Browse button.) For example, you can specify:

attrib

and the attributes should be:

-r $(file)

Then type into the Name: field a short name you wish to use to the command, for instance, TmpWritable.

Now clicking the Tools menu item you will see that the new sub-menu item TmpWritable Ctrl+3 appears. So you can call the inserted command by both pressing onto the hot key Ctrl+3 and by selecting this new sub-menu command Tools | TextPad.

Command Line Syntax

Notice that in the Command Line you should not surround a filename to be executed with the quotation marks, the IDE makes this automatically. However, you should surround a filename to be executed with quotation marks (if the filename contains blank characters) when you use it inside a command file. Also notice that the IDE passes the following parameters to the specified command line:

  • $(file:pne) – is the full filename (with the path and the filename extension) of the file opened in the having focus IDE editor.
  • $(file:p) – is the full path of the filename (i.e. without the filename) of the file opened in the having focus IDE editor.
  • $(file:n) – is the filename without the path and without the extension of the file opened in the having focus IDE editor.
  • $(file:e) – is the filename extension without the path of the file opened in the having focus IDE editor.
  • $(file:ne) – is the short filename without the path of the file opened in the having focus IDE editor.
  • $(file:pn) – is the full filename without the extension of the file opened in the having focus IDE editor.
  • $(file) – is the full filename (with the path and the filename extension) of the file opened in the having focus IDE editor.
  • $(line) – is the number of the current line (where the caret is placed) in the having focus IDE text editor. It is always 0, if a non-text editor is the currently active editor.
  • $(column) – is the number of the current column number (where the caret is placed) in the having focus IDE text editor. It is always 0, if a non-text editor is the currently active editor.
  • $(repository) – is the repository path, which can be used for a source control system
  • $(password) – is the password, which can be used for a source control system
  • $(user) – is the user name, which can be used for a source control system
  • $(scfile) – is the file name with path in the source control system
  • $(host) – is the host address, which can be used for a source control system


The tools works on the active file (e.g. in the active editor).

$(column) The column in which the caret is placed
$(line) The line number in which the caret is placed
$(file) File name
$(file:p) Path of the file name
$(file:n) Name of the file name
$(file:e) Extension of the file name
$(file:pn) Path and name
$(file:ne) Name and extension
$(file:pne) Path, Name and extension (same as $(file) )


These variables are for use with a source control system (e.g. SourceSafe, Vault, etc):

$(repository) Source Control repository
$(scfile) Source Control file name

The values of these variable depends on the settings you have made in Tools -> Source Control Repositories....

If the file name is c:\xxx\yyy\zzz\aaa.pro and you have defined a repository RRR with Directory c:\xxx\yyy then these variables will get the values:

$(repository) = RRR
$(scfile) = $/zzz/aaa.pro

Such values are suitable for defining the CheckOut command (Ctrl+1) which the IDE will use for some operations if the file is read-only. (And of course if you press Ctrl+1).

The last variables from the list (i.e. $(password) $(user) $(host)) are partly nonsense. These are handy variables for use with the CheckOut command, but they are merely variables defined in Tools -> IDE Variables....

Finally, the variable $(ProDir) represents the directory in which Visual Prolog is installed.

How to 'Check In' a File in MS Visual Source Safe

Let us, for example, discuss - how we can use parameters passed to command lines in a command file with which we can in MS Visual Source Safe (VSS) set "Check In" marker to a file opened in any IDE editor. We can do this with the following steps:

  • Select the menu item Tools | Configure Tools to open the Tools dialog.
  • Select a not used command, for instance 2, and as Name type in Check In.
  • Now into the filed Command Line type in a command like this:
C:\Visual Prolog 6\Check_In.cmd

and attributes

$(file) $(file:p) $(file:ne) $(line) $(column) $(repository) $(scfile)
  • The file Check_In.cmd should contain code like this:
setlocal
set ssexe="v:\win32\SS.EXE"
set ssdir=v:\VIP6
cd "%2"
"%ssexe%" Checkin "%3" -I-
endlocal

This code contains Visual Source Safe command line options, which we will not discuss here, but this command file also uses parameters:

  • $(file:p) to get "a path to the file opened in the having focus IDE editor" and
  • $(file:ne) to get "the filename (with a filename extension) of this file"

Now you can open a file (stored in a Visual Source Safe database) in an appropriate IDE editor (for example, in the IDE Designer) and press the hot key Ctrl+2 (or select the Tools | VSS Check In menu command). This will execute the Check_In.cmd file, which will "Check In" the opened file. This operation will copy your changes into the VSS database, creating a new version of the file containing the dialog description in VSS database. When other users use the Get Latest Version command or "Check out" the file, they receive all modifications you have made in this dialog.

How to 'Check Out' a File in Vault

Let us discuss how to Check Out a file opened in some IDE editor into the Vault repository (database).

Like in the previous paragraph we should:

  • Create a command file activating Vault, forming and executing correspondent Vault command to the edited file.
  • Add the call to this command file into the list of IDE commands.

For example, you can add a command activating this command file like these:

Ide Tools.png

Then the Tools sub-menu will look like this:

Ide Tools menu.png

Now if a file is opened in some IDE editor, then you can apply to it Vault's Check Out command simply pressing the Ctrl+1 hot key (or with the Tools | Check Out menu commands).

Let us shortly discuss contents of the Check_Out.cmd batch file. But first we should set the attributes:

$(scfile) $(repository) $(password) $(user) $(host)

What commands can be in the Check_Out.cmd file:

set USER=%4
set PW=%3
set HOST=%5
set REPOSITORY=%1
set LOGIN=-user "%USER%" -password "%PW%" -host "%HOST%" -repository "%REPOSITORY%"
set HOME=C:\Program Files\SourceGear\Vault Client
set CMD="%HOME%\vault.exe" "%LOGIN%"
"%CMD%" checkout %1

Here first lines prepare the LOGIN command, which will be passed to the Vault command line executable. These lines is rather simple and do not require additional explanations.

The next two lines prepare the CMD command, which will be used to call the command line version of the Vault client application vault.exe and pass to it the LOGIN parameters with which it will connect to the Vault server.

And the last line is the real checkout Vault command, which check out the specified file. For more information about Vault command line parameters use Vault help.