关于DELPHI控制FOXPRO数据库的一系列问题(200分)

  • 主题发起人 主题发起人 bobbycpu
  • 开始时间 开始时间
B

bobbycpu

Unregistered / Unconfirmed
GUEST, unregistred user!
问题1:我用Apollo VCL 6.0用Fts控件检查当前记录是否是假删除但总是报错,代码如下:
while apollotable1.eof<>true do
begin
if Fts1.IsDelete(apollotable1.RecNo)=1 then
begin
apollotable1.ApolloGetRecord(dataString );
apollotable2.AppendBlank;
apollotable2.Post;
apollotable2.edit;
apollotable2.PutRecord(dataString );

end
else

apollotable1.Next;
end;
但返回值为什么是-18,我不明白,首先apollotable1 and apollotable2都已独占打开。
问题2:我想调用foxpro的prg文件的执行,怎么调用法??
这些问题困扰了好久,希望大家能帮我解答,先谢谢了!
 
问题1:
没用过apollotable.你要说清楚是调用哪个函数的返回值啊?
(apollotable有没有帮助文件,查一下-18的错误值代表什么.)
if Fts1.IsDelete(apollotable1.RecNo)=1 then
可以改为if Fts1.IsDelete(apollotable1.RecNo) then 吧?
问题2:
delphi本身没办法运行prg,除非有相关的第三方控件.
如果只是简单的prg你可以用shellexecute调用vfp,并使用适当的vfp参数.
但是prg和你的delphi程序交互,有一定难度.

建议:多看看帮助文档,delphi的和apollotable的.
 
Fts1.isdeleted()返回类型为integer,1表示该记录是假删除状态,0表示该记录不是假删除状态
返回-18是句柄出错,但至于哪个句柄我没有查出来,而且Help里的范例也是这么写,我真不明
 
1、你跟踪一下 apollotable1.RecNo 是多少,是不是你预期的数字
2、WinExec( 'c:/目录/vfp.exe c:/nnnnn/xxxx.prg',SW_NORMAL); 执行prg
 
问题1:apollotable1.recno我试过了,是我预期的数字
问题2:PRG返回的值能否传到DELPHI里面吗?这样的做法可行,我试过了,但无法得到PRG
里的返回值。
谢谢!
 
问题1。检查一下Fts空件的属性有没有设全?我没用过这个空件,但是根据设计想法,
他应该有指定和foxpro表对象等属性的属性。看一下你帮助你面使用fts控件一般要
先设置好哪几个属性,然后才可以正常使用。

问题2。winexec和shellexcute差不多。
winexec( 'c:/目录/vfp.exe c:/nnnnn/xxxx.prg',SW_NORMAL);
->
ShellExecute(handle,nil,pchar(c:/目录/vfp.exe),pchar(c:/nnnnn/xxxx.prg),nil,sw_normal)
rpg我不熟悉,我有个笨办法:参数传递用dll试一下,不知道行不行???
我的思路是这样的:
在dll里面定义一个全局变量。两个函数setmyvar(var a:integer);getmyvar(var a:integer);
如果没有明确的释放dll,则dll全局变量会一直呆在内存。
foxpro 调用dll很方便,查帮助就知道,foxpro使用setmyvar把算出的值存进,delphi
getmyvar得出值。

还有个思路,写文本,读文本。
还有,写clipboard,读clipboard.

但是这些方法如果开多个线城可能就有问题。算了,麻烦还是很多。
让pipi帮你想吧。
 
Fts没有属性只有方法,我也很不理解,它好象没有指定那个apollotable,apollotable1.recno
返回的只是一个integer型的数字,这个控件怎么去理解的我也不明白,这样吧,可以的话我把
这个控件传给你,好吗?QQ:17565688,认证时请打你的DELPHIBBS上的名字,我就知道了
关于PRG的问题我搞定了,谢谢!
 
fts(fast text search)是快速文本搜索引擎,使用它要先初始化一下:
下面是摘录自vcl60/MAINDIR/Samples/Delphi/FTSDEMO例子一段代码(建议这个例子认真看看):
procedure TForm1.Open1Click(Sender: TObject);
var
sIdxName : String;
lRecno: Longint;
begin

{ Create HitList object }
HitList := TStringList.Create;
HitList.Duplicates := dupIgnore;

if OpenDialog1.Execute then
begin

{ Close any currently-active table }
if ApDS1.Active then
Close1Click( Sender );

{ Open Table }
ApDS1.DatabaseName := ExtractFilePath( OpenDialog1.FileName );
ApDS1.TableName := ExtractFileName( OpenDialog1.FileName );
ApDS1.Open;
edSearch.Enabled := True;

case Ord( ApDS1.TableType ) of
Ord(ttSXFOX): panTableType.Caption := 'TableType: ttSXFOX';
Ord(ttSXNTX): panTableType.Caption := 'TableType: ttSXNTX';
Ord(ttSXNSX): panTableType.Caption := 'TableType: ttSXNSX';
end;

{ Change file extension to .IA }
sIdxName := ChangeFileExt( OpenDialog1.FileName, '.IA' );

{ See if index already exists. If so, open it; If not, create it }
GetMem( cpIdxStr, ApDS1.RecSize+1 );
if FileExists( sIdxName ) then
Fts1.Open( sIdxName, 20, FTS_EXCL )
else
begin
ShowMessage( 'Creating ' + sIdxName );
Fts1.CreateIndex( sIdxName, 20, 2, True, 1 );
Gauge1.Visible := True;
lRecNo := 0;
with ApDS1 do
begin
Gauge1.Max := RecCount;
GoTop;
Screen.Cursor := crHourGlass;
while not Eof do
begin
ApolloGetRecord( cpIdxStr );
lRecno := Fts1.Add( cpIdxStr );
if lRecno < 0 then
ShowMessage( 'Error Adding Key: ' + IntToStr( lRecno ));

Gauge1.Position := Trunc( lRecno );
Skip( 1 );

{ Allows moving form, switching windows, etc., during processing }
Application.ProcessMessages;
end;
GoTop;
end;

{ IMPORTANT: Close and reopen the .IA file to _insure_ flushed buffers }
Fts1.Close;
Fts1.Open( sIdxName, 20, FTS_EXCL );

Gauge1.Position := Trunc( lRecno );
Screen.Cursor := crDefault;
Gauge1.Visible := False;
Gauge1.Position := 0;
sLastSrch := '';
end;
ShowMessage( IntToStr( Fts1.NumRecs ) + ' keys in ' + sIdxName + '.' );

{ Display Grid and set focus to Search box }
DBGrid1.Visible := True;
Close1.Enabled := True;
edSearch.SetFocus;
end;
 
apollotable的deleted属性,返回当前纪录是否删除:true删除,false没删除.
改了一下你的代码,不知道你是不是这个意思:
apollotable1.First;
while apollotable1.eof<>true do
begin
if Apollotable1.Deleted then //只这里改了一下,判断是否删除用Deleted即可,没必要用fts
begin
apollotable1.ApolloGetRecord(dataString );
apollotable2.AppendBlank;
apollotable2.Post;
apollotable2.edit;
apollotable2.PutRecord(dataString );
end
else

apollotable1.Next
end;
 
接受答案了.
 
后退
顶部