The mainapp object let you get access to some properties and methods used in the main
application. All you have to do is to type "MainApp." and all the properties and methods available
are listed in a listbox. They are also listed below.
Properties
AppPath
Syntax
AppPath: WideString (read-only)
Description
Path to the folder where the main program and tools are located.
AppDataPath
Syntax
AppDataPath: WideString (read-only)
Description
Path to the application data folder.
Example
var
sz: WideString;
begin
sz := MainApp.AppDataPath + '\Syntax\PHP.syx';
MainApp.OpenFile(sz);
...
end.
CurrentFolder
Syntax
CurrentFolder: WideString
Description
Path displayed in the sidebar explorer.
Example
MainApp.CurrentFolder := 'C:\\MyFolder';
CurrentView
Syntax
CurrentView: Integer
Description
Set or get the current view.
You can use the folloing values:
1 - Home
2 - Editor
3 - IE Preview
4 - Firefox Preview
5 - File Commander
DocumentCount
Syntax
DocumentCount: Integer (read-only)
Description
Get the number of open documents.
DocumentIndex
Syntax
DocumentIndex: Integer
Description
Get the tab index of the current document or change the tab index to set another
document to be the current.
ExeName
Syntax
ExeName: WideString (read-only)
Description
Get the file name of the main program, including path..
Height
Syntax
Height: Integer
Description
Height of the main window in pixels.
HInstance
Syntax
HInstance: Integer (read-only)
Description
Instance handle of the application.
hWnd
Syntax
hWnd: Integer (read-only)
Description
Handle to the main window.
Left
Syntax
Left: Integer
Description
Left coordinate of the main window.
Top
Syntax
Top: Integer
Description
Top coordinate of the main window.
Width
Syntax
Width: Integer
Description
Width of the main window in pixels.
WindowState
Syntax
WindowState: Integer
Description
Get or set the main window state.
You can use the following values:
0 - Normal
1 - Minimized
2 - Maximized
Methods
BringToFront
Syntax
BringToFront()
Description
Bring the main window to the front.
ClearMessageText
Syntax
ClearMessageText()
Description
Clear the text in the message field in the bottom bar.
CloseAll
Syntax
CloseAll(): Boolean
Description
Close all open documents. Return true if successful.
GetCurrentLanguageFileName
Syntax
GetCurrentlanguageFileName(): WideString
Description
Get the name of the currently used language file e.g. "eng.ini".
InputBox
Syntax
InputBox(const wsCaptions, wsPrompt: WideString): WideString
Description
Display a dialog box to obtain user input.
Example
var
s: WideString;
begin
s := InputBox('Name', 'Enter a user name:');
...
end.
NewDocument
Syntax
NewDocument(sFileExt: String)
Description
Create a new document.
Valid sFileExt could be:
.asp
.aspx
.php
.html
.css
.txt
...
An empty string will open a normal text file with no syntax highlighting.
NextDoc
Syntax
NextDoc()
Description
Move to the next document tab. Moves to the first tab if the last tab is showing.
OpenFile
Syntax
OpenFile(const wsFile: WideString; [const bReadOnly: Boolean]): Boolean
Description
Open the passed file. If the passed string is empty a file dialog is opened. Returns true if
the file opens or is already opened. The bReadOnly parameter is optional and will always
be False, if not set. Set bReadOnly to open the file in read-only mode.
PreviousDoc
Syntax
PreviousDoc()
Description
Move to the previous document tab. Moves to the last tab if the first tab is showing.
Quit
Syntax
Quit()
Description
Quit the program. The user will be prompted to save any unsaved documents.
RunApp
Syntax
RunApp(const wsFile, wsParam: WideString; bOutput, bMinimized: Boolean): Boolean
Description
Execute an external application. You can include a file name (with path) and a parameter.
Set bOutput to true in order to get the output from the program in the message view and
bMinimized if you want the application to start minimized.
Example
MainApp.RunApp('c:\Windows\notepad.exe', Document.FileName, False, False); //
Open the current document in notepad
RunAppAndWait
Syntax
RunAppAndWait(const wsFile, wsParam: WideString; bOutput, bMinimized: Boolean)
Description
Execute an external application and wait for it to finish. You can include a file name (with
path) and a parameter. Set bOutput to true in order to get the output from the program in
the message view and bMinimized if you want the application to start minimized.
Example
begin
MainApp.RunAppAndWait('c:\Windows\notepad.exe', Document.FileName, False, False); //
Open the current document in notepad and wait
Document.Reload(False);
end.
RunAppAndWaitF
Syntax
RunAppAndWaitF(const wsFile, wsParam, wsOutputFile: WideString; bMinimized:
Boolean)
Description
Execute an external application and wait for it to finish. You can include a file name (with
path) and a parameter. Set wsOutputFile to direct the output from the program to a file
and bMinimized if you want the application to start minimized.
SaveAll
Syntax
SaveAll(): Boolean
Description
Save all documents. Returns true if successful.
SendToBack
Syntax
SendToBack()
Description
Send the main window to the back.
SetMessageText
Syntax
SetMessageText(const wsText: WideString; [const bAppend: Boolean = False])
Description
Display text in the message field in the bottom bar. The bAppend argument is optional
and defaults to False. If you set bAppend to True, the text will be appended to the already
displayed text in the message field.
SetStatusText
Syntax
SetStatusText(wsMessage: WideString)
Description
Set the text to be displayed in the status area.
Wait
Syntax
Wait(nMilliseconds: Integer)
Description
Pause for given number of milliseconds. Use wait to enable scripts to execute loops and
still allow access to the UI. Without the call to Wait in the loop, the application appears
locked and the user cannot change views.
Example
begin
...
while MainApp.CurrentView = 2 do
MainApp.Wait(100);
//
Do something when the view has changed
...
end.