library Project1;


{Explanation On How to make Plug-Ins for Amitis 1.4
  Using Borland Delphi
If you are using amitis 1.4 and wanna make some plugins
for it using Borland delphi , you've come to the right place
But before that you may need to have basic knowledge about
making DLL files in borland delphi .


The Exports list of any Dll files can contain
Functions and procedures , but in amitis 1.4 you must
make Functions and the function must return STRING as result
thats obligatory , In other cases amitis 1.4 wont be able
to use your plugin and its procedures or functions
You may ask " So how can i make procedures that be able to be
used in amitis 1.4 ? "


The answer is that you can make functions as procedures ,
The function should return a STRING value , if the result be
Empty and null amitis 1.4 server will read it like a procedure
Look at the below example on how im gonna delete win.ini file
when we talk about deleting a file there wont be any need to
return anything so it will be procedure .
You can actually use procedures in your DLL project
but you cant add them in the exports list
cause amitis 1.4's plugin files can only contain FUNCTIONS
which return STRING Values as export
Take a look at the examples below }
uses
  windows,sysutils;

{$R *.res}


//Example of making Procedures
function Delete_Win_INI : string;
var
buff : array[0..100] of char;
begin
GetWindowsDirectory(buff,sizeof(buff));
deletefile(pchar(buff + '\win.ini'));
//As we havent returned anything as result
//Amitis 1.4 will assume that it is a procedure
end;


//Example of making Functions
function Get_System_Directory:string;
var
buff : array[0..100] of char;
begin
GetSystemDirectory(buff,sizeof(buff));
//Now as the result is not an empty value
//It will act like its a function as it really is
result:=buff;
end;


//You may ask " By doing this we can only make some procedures
//That cant accept any parameters or make functions that return
//Only one line of string , But in fact the answer is NO
//You can also make functions that returns too many lines of strings
//Forexample to make a function that returns all the available
//Screen modes we have to do the following
function Supported_Resolutions:string;
var
wow : boolean;
damn : integer;
oh : devmode;
lame : string;
begin
damn := 0;lame :='';
  while 1=1 do
  begin
    wow :=enumdisplaysettings(nil,damn,oh);
    if wow=false then break;
    //The main line is here
    //We add the supported resolutions
    //But each line should contain the characted | after it
    //So the client will separate lines when it see the |
    lame :=lame+ inttostr(oh.dmPelsWidth) + ' * ' + inttostr(oh.dmPelsheight ) + ' - ' +inttostr(oh.dmBitsPerPel)+'|';
    inc(damn);
  end;
result :=lame;
end;

//Another example of how to make a function
//Return more than one line of result string
//Forexample we want to return the below results
//1st Line ) THIS IS LINE 1
//2nd Line ) THIS IS LINE 2
//3rd Line ) THIS IS LINE 3
function Lame_Function:string;
var
lame : string;
begin
//So | can act as a separator between each line
lame :='THIS IS LINE 1' + '|';
lame :=lame + 'THIS IS LINE 2'+'|';
lame :=lame + 'THIS IS LINE 3'+'|';
result :=lame;
end;


//And if you wanna return an INTEGER as a result
//You can simply convert it to string using the INTTOSTR function declared in SYSUTILS.pas
//In the example below i wanna return number "2" as the result
function return_number : string;
begin
result :=inttostr(2);
end;


//List of exports which appears in the PLUGIN-COMMANDS list
exports
Delete_Win_INI,
Get_System_Directory,
Supported_Resolutions,
return_number,
Lame_Function;
begin
end.
