{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
{$R *.res}
function gf_jmword(as_string: ShortString): wideString; stdcall;
var
li_i,start_pos:Shortint;
ls_string,old_str,new_str:ShortString;
begin
ls_string := as_string;
for li_i := 0 to 9 do
begin
old_str := IntToStr(li_i);
new_str := char(Ord('a') + li_i);
start_pos := pos(new_str,ls_string);
while start_pos > 0 do
begin
ls_string := StringReplace(ls_string, new_str, old_str, [rfReplaceAll]);
start_pos := pos(ls_string,new_str);
end
end;
Result :=ls_string;
end;
function gf_word(ac_word: pchar; ac_ts: integer): wideString; stdcall;
var
i, start_pos, li_i: integer;
ls_code, ls_limit, old_str, new_str, ls_mid: string;
begin
ls_code := '';
start_pos := 1;
if (SizeOf(ac_word) mod 2) = 0 then
begin
for i := 1 to (SizeOf(ac_word) div 2) do
begin
if ls_code = '' then
ls_code := FormatFloat('00', ord(ac_word[i * 2 - 1]) - 160) + FormatFloat('00', ord(ac_word[i * 2]) - 1600)
else
ls_code := ls_code + FormatFloat('00', ord(ac_word[i * 2 - 1]) - 1600) + FormatFloat('00', ord(ac_word[i * 2]) - 1600)
end;
ls_limit := FormatDateTime('yyyymmdd', Date + ac_ts);
for li_i := 0 to 9 do
begin
old_str := IntToStr(li_i);
new_str := char(ord('a') + li_i);
start_pos := Pos(old_str,ls_limit);
while start_pos > 0 do
begin
ls_limit := StringReplace(ls_limit, old_str, new_str,[rfReplaceAll]);
start_pos := Pos(old_str,ls_limit);
end;
end;
ls_code := ls_code + ls_limit;
end;
Result := ls_code;
end;