Hi
I'm trying to write a function to dynamically export the active db.
When I run tbl.export() I get a "file is being used by another process" error. But:
- The only windows open in Alpha are the control panel and code editor. I've re-launchec Alpha to make sure there's nothing running in the background.
- Stored export operations on the same tables run OK.
I'm stuck - I'd appreciate advice.
Here's the relevant code:
"""""""""""""""""""""""""""""""""""""""""""
function export_db( )
'List the dbf files
db_path = a5.get_name( )
all_tables_list = load_adb_def( db_path, 0 )
'Strip out the sets
dim tables_list[1] as c
for each table in all_tables_list
if regex_match( table, "^.*\.dbf$") = .t. then
tables_list[] = table.value
end if
next
'Export all fields of each table as an Excel file
dim tbl as p
for each table_file in tables_list
tbl = table.open( table_file )
'List the fields
field_list = tbl.field_info_dump( "n" )
num_fields = w_count( field_list, crlf() )
export.file = table_file.value
export.type = FILE_FORMAT_EXCEL_VERSION_4
export.names = .t.
export.fields = num_fields
i = 1
for each field_name in field_list
property_str = "export.field"+i
eval( property_str ) = field_name.value
i = i + 1
next
tbl.export( )
tbl.close( )
next
"snip...."
end function
I'm trying to write a function to dynamically export the active db.
When I run tbl.export() I get a "file is being used by another process" error. But:
- The only windows open in Alpha are the control panel and code editor. I've re-launchec Alpha to make sure there's nothing running in the background.
- Stored export operations on the same tables run OK.
I'm stuck - I'd appreciate advice.
Here's the relevant code:
"""""""""""""""""""""""""""""""""""""""""""
function export_db( )
'List the dbf files
db_path = a5.get_name( )
all_tables_list = load_adb_def( db_path, 0 )
'Strip out the sets
dim tables_list[1] as c
for each table in all_tables_list
if regex_match( table, "^.*\.dbf$") = .t. then
tables_list[] = table.value
end if
next
'Export all fields of each table as an Excel file
dim tbl as p
for each table_file in tables_list
tbl = table.open( table_file )
'List the fields
field_list = tbl.field_info_dump( "n" )
num_fields = w_count( field_list, crlf() )
export.file = table_file.value
export.type = FILE_FORMAT_EXCEL_VERSION_4
export.names = .t.
export.fields = num_fields
i = 1
for each field_name in field_list
property_str = "export.field"+i
eval( property_str ) = field_name.value
i = i + 1
next
tbl.export( )
tbl.close( )
next
"snip...."
end function
Comment