各位朋友,函数如下,但其中有很多不明白的地方,请各位朋友赐教,多谢!!!!
function makeParam(const FieldType: TFieldType; const paramVal: variant): string;
begin
if paramVal = null then
begin
result := 'Null';
exit;
end; case FieldType of
ftString, ftMemo, ftFmtMemo, ftFixedChar, ftWideString: result := QuotedStr(trim(paramVal));
//问题1:请问什么是ftString,什么ftMemo,什么是ftFixedChar, ftWideString? ftSmallint, ftInteger, ftWord, ftLargeint:
//问题2:请问什么是ftSmallint、ftInteger, ftWord, ftLargeint?
begin
if string(paramVal) <> '' then
//问题3:if string(...)这句表示什么意思呢?为什么可以这样用?
result := paramVal
else
result := 'Null';
end;
ftBoolean: if paramVal then
result := '1'
else
result := '0';
ftFloat, ftCurrency, ftBCD:
begin
if checkstrtoFloat(paramVal) then
//问题4:if checkstrtoFloat(paramVal) then。这句又表示什么,挺难理解的
result := paramVal
else
result := 'Null';
end;
ftDate, ftTime, ftDateTime:
begin if SameText('getdate()', paramVal) then
//问题5:getdate()这个函数是不是取得当前系统的日期,而整个句子又是表示什么意思呢?
result := 'getdate()'
else
if paramVal <> '' then
result := '''' + formatdatetime('YYYY-MM-DD HH:NN:SS', strtodatetime(paramVal)) + ''''
else
result := 'Null';
end; end;
end;以上6个问题请各位朋友赐教,多谢!!!!!!
function makeParam(const FieldType: TFieldType; const paramVal: variant): string;
begin
if paramVal = null then
begin
result := 'Null';
exit;
end; case FieldType of
ftString, ftMemo, ftFmtMemo, ftFixedChar, ftWideString: result := QuotedStr(trim(paramVal));
//问题1:请问什么是ftString,什么ftMemo,什么是ftFixedChar, ftWideString? ftSmallint, ftInteger, ftWord, ftLargeint:
//问题2:请问什么是ftSmallint、ftInteger, ftWord, ftLargeint?
begin
if string(paramVal) <> '' then
//问题3:if string(...)这句表示什么意思呢?为什么可以这样用?
result := paramVal
else
result := 'Null';
end;
ftBoolean: if paramVal then
result := '1'
else
result := '0';
ftFloat, ftCurrency, ftBCD:
begin
if checkstrtoFloat(paramVal) then
//问题4:if checkstrtoFloat(paramVal) then。这句又表示什么,挺难理解的
result := paramVal
else
result := 'Null';
end;
ftDate, ftTime, ftDateTime:
begin if SameText('getdate()', paramVal) then
//问题5:getdate()这个函数是不是取得当前系统的日期,而整个句子又是表示什么意思呢?
result := 'getdate()'
else
if paramVal <> '' then
result := '''' + formatdatetime('YYYY-MM-DD HH:NN:SS', strtodatetime(paramVal)) + ''''
else
result := 'Null';
end; end;
end;以上6个问题请各位朋友赐教,多谢!!!!!!
这是D定义TFieldType类的类型名称;
TFieldType is a set of values that parallel the data types of fields in tables.//--原文;
也就是说,字段类型所包含的种类;ftString:表示当前字段对应数据类型为字符串类型;。
//问题2:请问什么是ftSmallint、ftInteger, ftWord, ftLargeint?
请参考1的回答;
//问题3:if string(...)这句表示什么意思呢?为什么可以这样用?
在这里STRING()是一种强制类型转换。意思是将paramVal的值转换成字符串,
if string(paramVal) <> '' then//--如果能将paramVal成功转换成字符串则执行下续操作;//问题4:if checkstrtoFloat(paramVal) then。这句又表示什么,挺难理解的
//问题5:getdate()这个函数是不是取得当前系统的日期,而整个句子又是表示什么意思呢?
在这里估计是自己定义了两个功能函数,第一个是用来检测参数类型是否为浮点数,
条二个用来检测参数是否是日期时间类型,如果是,再比较与当前日期是否相同;