在 2012 年 11 月 2 日添加了附加段落 - 我在调试时遇到了一种非常酷的方式来查看缓冲区数据,这对数据存储区最有用,但对于数据窗口应该可以正常工作。查看此站点部分Save DataStore from Debugger。
我常用的一种解决方法是将代码添加到 datawindow 控件(祖先更好)的单击事件,并使用 keydown 函数来确定前-已按下定义且晦涩的组合键。如果有,则数据应保存到文件。
我喜欢为最常见的类型创建隐藏的复活节彩蛋功能,包括一种提示用户输入文件类型和名称的通用类型。
ctl+alt+e 用于 Excel!
ctl+alt+t 用于文本!
ctl+alt+c 用于 CSV!
ctrl+alt+a 表示任意(使用另存为对话框提示)
因此,如果用户按住 ctrl+alt+e 并 单击数据对象上的任意位置,则会触发以下代码,从而将数据写入 excel,并且excel文件自动打开。我经常将此功能保留在生产应用程序中(有时我会根据数据的敏感程度过滤我的用户 ID),因为它是一个伟大的生产支持工具。我们的QA 部门也喜欢该功能,因为他们可以轻松记录数据,并且可以查看所有列,甚至是未显示的列。
long ll_handle
string ls_filename, ls_null, ls_dir
if keydown(KeyControl!) and keydown(KeyAlt!) then
// set work variables to be used in save
SetNull(ls_null)
// grab handle to MDI frame window for the ShellExecute function
ll_handle = Handle(gwMdi)
// construct the filename using dataobject and datetime
ls_dir = "c:\temp"
ls_filename = ls_dir + '\debug_dataobject_' + this.dataobject + '_date_' + string(Today(),'mmddyyhhmmss')
// determine if we are saving excel, text, csv, or prompting for filetype
if keydown(keye!) then
ls_filename =+ '.xls'
dw_1.SaveAs(ls_filename, Excel!,True!)
elseif keydown(keyt!) then
ls_filename =+ '.txt'
dw_1.SaveAs(ls_filename, Text!,True!)
elseif keydown(keyc!) then
ls_filename =+ '.txt'
dw_1.SaveAs(ls_filename, Csv!,True!)
elseif keydown(keya!) then
ls_filename =+ ''
// empty string forces dialog open
dw_1.SaveAs(ls_filename)
end if
// now automatically open the file using default program
// for the file type via Windows API function
if fileexists(ls_filename) then
gwMdi.ShellExecute(ll_handle, 'open', ls_filename, ls_null, ls_dir, 3)
end if
end if
// Define ShellExcecute as Local External Function
// somewhere in your application or as Global External Function:
Function Long ShellExecute (Long hWnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory, Long nShowCmd) Library "shell32.dll" Alias For "ShellExecuteA"
这不是您想要的,但它确实有效!
HTH