|
일단 델파이 시작한지 약 2시간 정도 되어 갑니다. 에러도 해결할 능력이 안됨은 미리 말씀 드립니다.
컴파일 소스를 dll로 만드는 작업을 하고 있는데요.
소스 컴파일시 에러가 떠너 질문 드립니다.
질문 1. word를 string으로 캐스팅 하려면 어떻게 해야 하나요?
질문 2. 컴파일 에러 인데 이런 경우는 어떻게 해야 할까요?
------------------------------------------------------
library MyUDF;
{ 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}
const
kk : array [0..162, 0..12] of char
=('1212122322121', // 1881
'1212121221220',
'1121121222120',
'2112132122122',
'2112112121220',
'2121211212120',
'2212321121212',
'2122121121210',
'2122121212120',
'1232122121212',
'1212121221220', // 1891
'1121123221222',
'1121121212220',
'1212112121220',
'2121231212121',
'2221211212120',
'1221212121210',
'2123221212121',
'2121212212120',
'1211212232212',
'1211212122210', // 1901
'2121121212220',
'1212132112212',
'2212112112210',
'2212211212120',
'1221412121212',
'1212122121210',
'2112212122120',
'1231212122212',
'1211212122210',
'2121123122122', // 1911
'2121121122120',
'2212112112120',
'2212231212112',
'2122121212120',
'1212122121210',
'2132122122121',
'2112121222120',
'1211212322122',
'1211211221220',
'2121121121220', // 1921
'2122132112122',
'1221212121120',
'2121221212110',
'2122321221212',
'1121212212210',
'2112121221220',
'1231211221222',
'1211211212220',
'1221123121221',
'2221121121210', // 1931
'2221212112120',
'1221241212112',
'1212212212120',
'1121212212210',
'2114121212221',
'2112112122210',
'2211211412212',
'2211211212120',
'2212121121210',
'2212214112121', // 1941
'2122122121120',
'1212122122120',
'1121412122122',
'1121121222120',
'2112112122120',
'2231211212122',
'2121211212120',
'2212121321212',
'2122121121210',
'2122121212120', //1951
'1212142121212',
'1211221221220',
'1121121221220',
'2114112121222',
'1212112121220',
'2121211232122',
'1221211212120',
'1221212121210',
'2121223212121',
'2121212212120', // 1961
'1211212212210',
'2121321212221',
'2121121212220',
'1212112112210',
'2223211211221',
'2212211212120',
'1221212321212',
'1212122121210',
'2112212122120',
'1211232122212', // 1971
'1211212122210',
'2121121122210',
'2212312112212',
'2212112112120',
'2212121232112',
'2122121212110',
'2212122121210',
'2112124122121',
'2112121221220',
'1211211221220', // 1981
'2121321122122',
'2121121121220',
'2122112112322',
'1221212112120',
'1221221212110',
'2122123221212',
'1121212212210',
'2112121221220',
'1211231212222',
'1211211212220', // 1991
'1221121121220',
'1223212112121',
'2221212112120',
'1221221232112',
'1212212122120',
'1121212212210',
'2112132212221',
'2112112122210',
'2211211212210',
'2221321121212', //2001
'2212121121210',
'2212212112120',
'1232212121212',
'1212122122110',
'2121212322122',
'1121121222120',
'2112112122120',
'2211231212122',
'2121211212120',
'2122121121210', // 2011
'2124212112121',
'2122121212120',
'1212121223212',
'1211212221220',
'1121121221220',
'2112132121222',
'1212112121220',
'2121211212120',
'2122321121212',
'1221212121210', // 2021
'2121221212120',
'1232121221212',
'1211212212210',
'2121123212221',
'2121121212220',
'1212112112220',
'1221231211221',
'2212211211220',
'1212212121210',
'2123212212121', // 2031
'2112122122120',
'1211212322212',
'1211212122210',
'2121121122120',
'2212114112122',
'2212112112120',
'2212121211210',
'2212232121211',
'2122122121210',
'2112122122120', // 2041
'1231212122212',
'1211211221220');
dt : array [0..162] of Integer
=(384, 355, 354, 384, 354, 354, 384, 354, 355, 384,
355, 384, 354, 354, 383, 355, 354, 384, 355, 384,
354, 355, 383, 354, 355, 384, 354, 355, 384, 354,
384, 354, 354, 384, 355, 354, 384, 355, 384, 354,
354, 384, 354, 354, 385, 354, 355, 384, 354, 383,
354, 355, 384, 355, 354, 384, 354, 384, 354, 354,
384, 355, 355, 384, 354, 354, 384, 354, 384, 354,
355, 384, 355, 354, 384, 354, 384, 354, 354, 384,
355, 354, 384, 355, 353, 384, 355, 384, 354, 355,
384, 354, 354, 384, 354, 384, 354, 355, 384, 355,
354, 384, 354, 384, 354, 354, 385, 354, 355, 384,
354, 354, 383, 355, 384, 355, 354, 384, 354, 354,
384, 354, 355, 384, 354, 384, 354, 354, 384, 354,
354, 384, 355, 384, 355, 354, 384, 354, 354, 384,
354, 355, 384, 354, 384, 355, 354, 383, 355, 354,
384, 355, 384, 354, 354, 384, 354, 354, 384, 355,
355, 384, 354);
m : array[0..11] of byte = (31,28,31,30,31,30,31,31,30,31,30,31);
function sol2lun1p(solYear: Word; solMonth: Word; solDay: Word): string; export;
var
m0, m1, m2 : Integer;
i, j : Integer;
temp : Integer;
acc_day : LongInt;
buff_day : LongInt;
total_day : LongInt;
lunYear: Word; lunMonth: Word; lunDay: Word; isLeap: Boolean;
begin
// 총 일수를 계산한다.
temp := solYear - 1;
total_day := temp*365 + Trunc(temp/4) - Trunc(temp/100) + Trunc(temp/400);
if ((solYear mod 4=0) and not (solYear mod 100=0)) or
// *************************************
// 에러발생 *****************************
// m 이라는 배열을 함수 밖에서 선언했는데 이것이 잘못 인듯 합니다.
// *************************************
(solYear mod 400=0) then m[1] := 29 else m[1] := 28;
for i := 0 to solMonth-2 do total_day := total_day + m[i];
total_day := total_day + solDay;
// 총 일수 - 1880년까지의 총 일수
acc_day := total_day - 686686 + 1;
// Lunar Year
buff_day := dt[0];
for i := 0 to 162 do begin
if acc_day <= buff_day then break;
buff_day := buff_day + dt[i+1];
end;
lunYear := i + 1881;
// Lunar Month
buff_day := buff_day - dt[i];
acc_day := acc_day - buff_day;
if kk[i][12] <> '0' then temp := 13 else temp := 12;
m2 := 0;
for j := 0 to temp-1 do begin
if kk[i][j] <= '2' then begin
inc(m2);
m1 := StrToInt(kk[i][j]) + 28;
end else
m1 := StrToInt(kk[i][j]) + 26;
if acc_day <= m1 then break;
acc_day := acc_day - m1;
end;
m0 := j;
lunMonth := m2;
// Lunar Day
lunDay := acc_day;
if (kk[lunYear-1881][12] <> '0') and (kk[lunYear-1881][m0] > '2') then
isLeap := true else isLeap := false;
// *************************************
// 에러발생 *****************************
// 캐스팅 에러 인듯 합니다.
// *************************************
Result:= string(lunYear) + string(lunMonth) + string(lunDay);
end;
exports sol2lun1p;
begin
end.
------------------------------------------------------
|