|
|
Code repository: how and where.
Code repository is a chest full of pieces of code. Each piece of code can be inserted into a module with few mouse clicks. Code repository is accessible also via PaxDebugger component methods, on this we'll talk later in this tutorial.
A repository consist of code groups, and code aliases. Code groups are just a sort of folders, they contain zero or more code aliases.
A code alias is a piece of code, with a name (the alias name) and a (pax)language associated.
Through code repository editor, is possible to add and delete code aliases and groups.
To insert a code alias in the current edited module is very simple:
- Move the text editor cursor in the position you want to add code.
- Use 'Repository' menù, and click on 'Add code from repository' item. This will open th repository.
- Select the code alias and click ok.
- Now the code will be added in the current edited module at the cursor position .
The code repository is automatically saved by PaxDebugger when:
- The user exits from code repository editor and repository has been changed.
- The PaxDebugger component is destroying.
When repository is going to be saved, this is the used behavior:
- it will be saved on file if a project is present and the project is on file.
- it will be saved on database if no project is present.
- it will be saved on database if a project is present and the project is on database.
PaxDebugger component has a published property called RepositoryFileName. This is the filename used when repository will be on file. If a path is not specified in RepositoryFileName, the application path will be used.
When RepositoryFileName property is setted, PaxDebugger try to load this file immediately. If this file exists, then the entire repository is first cleared, then file is loaded and repository filled with groups and aliases.
The repository can be filled also via code, here's a typical example on how to fill it using a db-based approach:
procedure FillDBRepository;
var
i, recsCount: integer;
record: <RecordClass>; alias: TPaxDebuggerCodeAlias; begin <Open database> recsCount := <GetRecordsCount>; for i := 1 to recsCount do begin record := <ReadRecord_FromDataBase>; PaxDebugger.AddCodeToRepository(record.AliasName, record.GroupName,
<GetLanguageFromInfos(record.langInfo)>, alias); if (Assigned(alias)) then alias.CodeText := record.CodeText else ShowMessage('PaxDebugger cannot add code alias'); end; <Close database>
PaxDebugger.ImposeRepositoryLoaded; end;
At any moment, the entire repository can be cleared with ClearRepository public method.
|
|