?? unit1.~pas
字號:
unit Unit1;
////////////////////////////////////////////////////////////////////////////////
//
// 要增加一個全局命令,請:
// 1.編寫命令的實現(xiàn)函數(shù),原形為pFN_EXECUTE_CMD;
// 2.設置常量CommandsCount值加一;
// 3.在InitImpCommands函數(shù)中,初始化數(shù)組成員InitImpCommands[CommandsCount-1];
// 4.在InitArgumentsInfo函數(shù)中,增加一個CASE(即初始化數(shù)組成員ArgumentsInfo[CommandsCount-1][]);
// 5.在InitCommandsInfo函數(shù)中,增加一個CASE(即初始化數(shù)組成員CommandsInfo[CommandsCount-1]);
// 6.在InitLibInfo函數(shù)中,修改庫的版本號(本步可省略)。
//
// 要增加一個常量,請:
// 1.在InitConstInfo函數(shù)中,增加一個CASE(初始化數(shù)組成員ConstsInfo[InitConstInfo-1];
// 2.設置常量ConstsCount值加一;
// 3.在InitLibInfo函數(shù)中,修改庫的版本號(本步可省略)。
//
////////////////////////////////////////////////////////////////////////////////
interface
uses Windows, elibTypes;
const
CommandsCount = 2; //!!! 命令個數(shù)
ConstsCount = 1; //!!! 常量個數(shù)(如果為0,請把常量信息數(shù)組ConstsInfo的定義行注釋掉,同時把函數(shù)InitConstInfo中的代碼清除)
var
LibInfo : LIB_INFO;
CommandsInfo : array[0..CommandsCount-1] of CMD_INFO; // 命令信息
ArgumentsInfo: array[0..CommandsCount-1] of array of ARG_INFO; // 參數(shù)信息
ImpCommands : array[0..CommandsCount-1] of pFN_EXECUTE_CMD; // 命令實現(xiàn)
ConstsInfo : array[0..ConstsCount-1] of LIB_CONST_INFO; // 常量信息
function ProsessNotify (nMsg:Integer; dwParam1:LongWord=0; dwParam2:LongWord=0) :Integer; stdcall;
function AddInFunction (nAddInFnIndex:Integer) :Integer; stdcall;
//----------------------------------------------------------------------------
// 唯一的輸出函數(shù) GetNewInf() 的聲明
function GetNewInf () : pLIB_INFO; stdcall; export;
//----------------------------------------------------------------------------
// 命令實現(xiàn)函數(shù)的聲明(所有函數(shù)的原形都是相同的,即pFN_EXECUTE_CMD)
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//左移
procedure usrSHL(pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;
//右移
procedure usrSHR(pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//----------------------------------------------------------------------------
// 內部初始化函數(shù)的聲明
procedure InitLibInfo; // 初始化庫信息
procedure InitCommandsInfo; // 初始化命令信息
procedure InitArgumentsInfo; // 初始化參數(shù)信息
procedure InitImpCommands; // 初始化命令實現(xiàn)信息
procedure InitConstInfo; // 初始化常量信息
////////////////////////////////////////////////////////////////////////////////
implementation
//uses Unit2, Unit5;
// 這是本庫唯一的輸出函數(shù)GetNewInf的定義
function GetNewInf () : pLIB_INFO; stdcall; export;
begin
Result:=@LibInfo;
end;
////////////////////////////////////////////////////////////////////////////////
// 初始化庫信息
procedure InitLibInfo;
begin
LibInfo.m_dwLibFormatVer:=LIB_FORMAT_VER;
LibInfo.m_szGuid:=PChar('713B2774F7664D27BDD048AA88900FC1'); //Ctrl+Shift+G
LibInfo.m_nMajorVersion:=1; // 主版本號
LibInfo.m_nMinorVersion:=0; // 次版本號
LibInfo.m_nBuildNumber:=0; // 構建版本號
LibInfo.m_nRqSysMajorVer:=3;
LibInfo.m_nRqSysMinorVer:=0;
LibInfo.m_nRqSysKrnlLibMajorVer:=3;
LibInfo.m_nRqSysKrnlLibMinorVer:=0;
LibInfo.m_szName:=PChar('*【移位擴展庫】* Roya Onfly'); // 支持庫名稱
LibInfo.m_nLanguage:=LT_CHINESE;
LibInfo.m_szExplain:=PChar('易語言移位擴展支持庫 Build 0414'+#13+#10+
' 諾亞鴻飛軟件工作室 吳江濤 '+#13+#10+
'------------------------------------------------------------------------------------------------------------------------'+#13+#10);
LibInfo.m_dwState:=0;
LibInfo.m_szAuthor:=PChar('吳江濤'); // 作者
LibInfo.m_szZipCode:=PChar('330034');
LibInfo.m_szAddress:=PChar('南昌航空工業(yè)學院290信箱');
LibInfo.m_szPhone:=PChar('0791-7066853');
LibInfo.m_szFax:=nil;
LibInfo.m_szEmail:=PChar('wujtao@91x.com');
LibInfo.m_szHomePage:=PChar('Http://wujtao.126.com');
LibInfo.m_szOther:=PChar('QQ:51273885(私人) 362666286(工作)'+#13+#10+
'------------------------------------------------------------------------------------------------------------------------'+#13+#10);
LibInfo.m_nDataTypeCount:=0;
LibInfo.m_pDataType:=nil;
LibInfo.m_nCategoryCount:=1;
LibInfo.m_szzCategory:=PChar('0024 邏輯移位'+#0);
LibInfo.m_nCmdCount:=CommandsCount;
LibInfo.m_pBeginCmdInfo:=@CommandsInfo;
LibInfo.m_pCmdsFunc:=@ImpCommands;
LibInfo.m_pfnRunAddInFn:=AddInFunction;
LibInfo.m_szzAddInFnInfo:=PChar('諾亞鴻飛軟件工作室'+#0);
LibInfo.m_pfnNotify:=ProsessNotify;
LibInfo.m_pfnSuperTemplate:=nil;
LibInfo.m_szzSuperTemplateInfo:=nil;
LibInfo.m_nLibConstCount:=ConstsCount;
LibInfo.m_pLibConst:=@ConstsInfo;
LibInfo.m_szzDependFiles:=nil;
end;
////////////////////////////////////////////////////////////////////////////////
// 初始化命令信息
procedure InitCommandsInfo;
var i:Integer;
begin
// 采用for+case的結構,可使新增一個命令或常量時,在復制、粘貼之后,盡可能減少修改代碼的次數(shù)。下同。
for i:=0 to High(CommandsInfo) do case i+1 of
1:// 第一個命令的信息---------------------------------------------------------
with CommandsInfo[i] do begin
m_szName:=PChar('左移');
m_szEGName:=PChar('SHL');
m_szExplain:=PChar('對數(shù)進行左移運算.');
m_shtCategory:=1;
m_wState:=0;
m_dtRetType:=SDT_INT;
m_wReserved:=0;
m_shtUserLevel:=LVL_HIGH;
m_shtBitmapIndex:=0;
m_shtBitmapCount:=0;
m_nArgCount:=High(ArgumentsInfo[i])+1;
m_pBeginArgInfo:=pARG_INFO(ArgumentsInfo[i]);
end;
2:// 第二個命令的信息---------------------------------------------------------
with CommandsInfo[i] do begin
m_szName:=PChar('右移');
m_szEGName:=PChar('SHR');
m_szExplain:=PChar('對數(shù)進行右移運算.');
m_shtCategory:=1;
m_wState:=0;
m_dtRetType:=SDT_INT;
m_wReserved:=0;
m_shtUserLevel:=LVL_HIGH;
m_shtBitmapIndex:=0;
m_shtBitmapCount:=0;
m_nArgCount:=High(ArgumentsInfo[i])+1;
m_pBeginArgInfo:=pARG_INFO(ArgumentsInfo[i]);
end;
end; // end of case and for
end;
////////////////////////////////////////////////////////////////////////////////
// 初始化參數(shù)信息
procedure InitArgumentsInfo;
var i,j,count:Integer;
begin
for i:=0 to High(ArgumentsInfo) do case i+1 of
1://以下是第一個命令的參數(shù)信息================================================
begin
count:=2; //!!! 本命令的參數(shù)個數(shù)
SetLength(ArgumentsInfo[i],count);
for j:=0 to High(ArgumentsInfo[i]) do case j+1 of
1: //第一個參數(shù)----------------------------------------------------------
with ArgumentsInfo[i][j] do begin
m_szName:=PChar('源數(shù)字');
m_szExplain:=PChar('該數(shù)是要進行左移運算的源數(shù)字(為整數(shù)型,最大長度4字節(jié)');
m_shtBitmapIndex:=0;
m_shtBitmapCount:=0;
m_dtDataType:=SDT_INT;
m_nDefault:=0;
m_dwState:=0;
end;
2: //第二個參數(shù)----------------------------------------------------------
with ArgumentsInfo[i][j] do begin
m_szName:=PChar('移位數(shù)');
m_szExplain:=PChar('該數(shù)是要進行左移運算的移位書,不能超過16');
m_shtBitmapIndex:=0;
m_shtBitmapCount:=0;
m_dtDataType:=SDT_INT;
m_nDefault:=1; //默認參數(shù)
m_dwState:=AS_HAS_DEFAULT_VALUE; //參數(shù)狀態(tài),有默認參數(shù)
end;
end; // end of case j+1 and for
end; // end of case i+1
2://以下是第二個命令的參數(shù)信息================================================
begin
count:=2; //!!! 本命令的參數(shù)個數(shù)
SetLength(ArgumentsInfo[i],count);
for j:=0 to High(ArgumentsInfo[i]) do case j+1 of
1: //第一個參數(shù)----------------------------------------------------------
with ArgumentsInfo[i][j] do begin
m_szName:=PChar('源數(shù)字');
m_szExplain:=PChar('該數(shù)是要進行右移運算的源數(shù)字(為整數(shù)型,最大長度4字節(jié)');
m_shtBitmapIndex:=0;
m_shtBitmapCount:=0;
m_dtDataType:=SDT_INT;
m_nDefault:=0;
m_dwState:=0;
end;
2: //第二個參數(shù)----------------------------------------------------------
with ArgumentsInfo[i][j] do begin
m_szName:=PChar('移位數(shù)');
m_szExplain:=PChar('該數(shù)是要進行右移運算的移位數(shù),不能超過16');
m_shtBitmapIndex:=0;
m_shtBitmapCount:=0;
m_dtDataType:=SDT_INT;
m_nDefault:=1; //默認參數(shù)
m_dwState:=AS_HAS_DEFAULT_VALUE; //參數(shù)狀態(tài),有默認參數(shù)
end;
end; // end of case j+1 and for
end; // end of case i+1
// 在此添加其它命令的參數(shù)信息
end; // end of case i+1 and for
end;
////////////////////////////////////////////////////////////////////////////////
// 初始化命令實現(xiàn)信息
// 在這里編寫用戶自定義的處理函數(shù)
procedure InitImpCommands;
begin
ImpCommands[0]:=usrSHL; //左移函數(shù)
ImpCommands[1]:=usrSHR; //右移函數(shù)
end;
////////////////////////////////////////////////////////////////////////////////
// 初始化常量信息
procedure InitConstInfo;
var i:Integer;
begin
for i:=0 to High(ConstsInfo) do case i+1 of
1://第一個常量----------------------------------------------------------------
with ConstsInfo[i] do begin
m_szName:=PChar('諾亞鴻飛');
m_szEGName:=PChar('Roya');
m_szExplain:=nil;
m_shtReserved:=1;
m_shtType:=CT_TEXT;
m_szText:=PChar('諾亞鴻飛軟件工作室 吳江濤');
m_dbValue:=0;
end;
//在此添加其它常量信息
end; // end of case and for
end;
////////////////////////////////////////////////////////////////////////////////
// 接受來自易IDE的通知,目的就是獲得向易IDE反饋信息的函數(shù)指針g_fnNotifySys(全局變量)
function ProsessNotify (nMsg:Integer; dwParam1:LongWord=0; dwParam2:LongWord=0) :Integer; stdcall;
var ReturnValue: Integer;
begin
ReturnValue:=NR_OK;
case nMsg of
NL_SYS_NOTIFY_FUNCTION:
g_fnNotifySys:=pFN_NOTIFY_SYS(dwParam1);
else ReturnValue:=NR_ERR;
end;
Result:=ReturnValue;
end;
////////////////////////////////////////////////////////////////////////////////
// 附加功能實現(xiàn)函數(shù)的定義(代碼實現(xiàn))
function AddInFunction (nAddInFnIndex:Integer) :Integer; stdcall;
begin
(*
AboutMe(nil,0,nil);
*)
MessageBox(0,pchar(nAddInFnIndex),'E-IDE Notify',MB_OK);
Result:=0;
end;
////////////////////////////////////////////////////////////////////////////////
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 命令實現(xiàn)函數(shù)的定義(代碼實現(xiàn))
// 在函數(shù)中可通過ArgArray(pArgInf)[i].m_Value讀取易傳過來的第i個參數(shù)(i從0開始,0表示第一個參數(shù))
procedure usrSHL (pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;
begin
//左移實現(xiàn)過程
pRetData.m_Value.m_int:=ArgArray(pArgInf)[0].m_Value.m_int SHL ArgArray(pArgInf)[1].m_Value.m_int;
end;
procedure usrSHR (pRetData:pMDATA_INF; nArgCount:Integer; pArgInf:pMDATA_INF); cdecl;
begin
//右移實現(xiàn)過程
pRetData.m_Value.m_int:=ArgArray(pArgInf)[0].m_Value.m_int SHR ArgArray(pArgInf)[1].m_Value.m_int;
end;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
////////////////////////////////////////////////////////////////////////////////
initialization
//////////////////////////////////////////////////////////////////////////////
// 初始化支持庫信息,以下函數(shù)的調用順序不可輕易變動
InitArgumentsInfo;
InitCommandsInfo;
InitImpCommands;
InitConstInfo;
InitLibInfo;
//////////////////////////////////////////////////////////////////////////////
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -