This script to correct the Alpha5 *.ADB file. This file is has the association to Alpha5. It is displayed with the Alpha5 icon and is the one that can be launched. This script corrects the ADB file for the currently open database.
This file contains the list of tables in the database. Sometimes the file list tables that actually no longer exits. This will cause errors in database compact operations and can affect shadow operations.
In my own situation my application had grown to over 130 tables. When compacting the database I found that any table deleted programmatically via a script versus the control panel was still visible in this file. Rather than manually compare all these file names I borrowed extensively from the application I am developing and produced this menu driven script.
Altough this script uses two documented ALPHA5 commands for reading and writing the ADB file this is as they say undocumented territory proceed at your own risk.
I would appreciate any feedback, was this useful helpful etc.
The following links give more details on ADB file and go me started on this mornings worth of work.
http://www.alphasoftware.com/alphafo...read.php?61580
http://alphafivewiki.com/LOAD_ADB_DEF+Function
http://alphafivewiki.com/SAVE_ADB_DEF+Function
This file contains the list of tables in the database. Sometimes the file list tables that actually no longer exits. This will cause errors in database compact operations and can affect shadow operations.
In my own situation my application had grown to over 130 tables. When compacting the database I found that any table deleted programmatically via a script versus the control panel was still visible in this file. Rather than manually compare all these file names I borrowed extensively from the application I am developing and produced this menu driven script.
Altough this script uses two documented ALPHA5 commands for reading and writing the ADB file this is as they say undocumented territory proceed at your own risk.
I would appreciate any feedback, was this useful helpful etc.
The following links give more details on ADB file and go me started on this mornings worth of work.
http://www.alphasoftware.com/alphafo...read.php?61580
http://alphafivewiki.com/LOAD_ADB_DEF+Function
http://alphafivewiki.com/SAVE_ADB_DEF+Function
Code:
'Date Created: 01-May-2015 11:09:10 AM 'Last Updated: 01-May-2015 12:56:26 PM 'Created By : verboopa2 'Updated By : verboopa2 '----------- 'Tool-ADBfix '----------- 'A program to correct the Alpha5 ADB file. 'This file contains the list of tables and in the database 'Sometimes the file list tables that actually no longer exits 'This will cause errors in database compact operations and can affect shodow operation. 'This program will list all databases files in the ADB and the ones that actually exist will be checked. 'You can manully check and uncheck files as well. '--------------------- '// Set Debug Flags -- '--------------------- DIM Debug as C = "" 'check debug flag with condition: if ("m" $ Debug) 'f - send DBF file list to trace window 'o - send othe rstuff to trace window 'n - DBF & DDM files not found 'w - write new ADB file to trace windoe instead of for real '--------------- '// Intialize -- '--------------- DIM DialogTtl as C = "Tool-ADBfix" DIM ADBfile as C 'The ADB file we are editing DIM ADBbackup as C 'The backup copy of the ADBfile created when we rewrite it DIM ADB as C 'The ADB file contents returned by the LOAD_ADB_DEF function DIM ADBout as C 'The modified version of ABD file written back out DIM LineIn as N 'Number of lines in orginal version DIm LineOut as N 'Number of lines in modified version DIM cLine as C 'character version of line read from list DIM DBFlist as C = "" 'List of DBF and DDM (data dictionary) files in database DIM OTHERlist as C = "" 'other stuff that we can edit manually and is just put back in file DIM DBFsel as C = "" 'DBF files that where verified to exist DIM DBFnoexist as C = "" 'DBF files that where not found DIM Mode as N = 0 'Mode we are in while parsing files '0 = do nothing still looking for something to trigger actions '1 = found file name marker trigger for actual reading file names '2 = now reading file names '3 = reading other stuff include markers '-------------------------------- '// Verify editing master copy -- '-------------------------------- IF A5.Get_Master_Name() 'Verify we are on the master installation ui_msg_box(DialogTtl,"Script should not be used on Shadowed installations",UI_ATTENTION_SYMBOL+UI_OK) end end if '------------------------------- '// Retrieve & Parse ADB file -- '------------------------------- ADBfile = A5.Get_Name() ADB = load_adb_def(ADBfile,1) LineIn = line_count(ADB) For each Line in ADB cLine = Line - "" 'Forced Line value into a character value from pointer value select 'select what we do based on contents of this line case cLine = ":files" 'marker for DBF DDD files set flag next line we start adding to list Mode = 1 case *leading(cLine,":") 'some otehr marker no longer looking at DBF & DDD files Mode = 3 case else IF Mode = 1 'files triggered so next line we start adding to file list Mode = 2 end if end select select case Mode = 2 'mode for adding to file list DBFlist = *concat_lines(DBFlist,cLine) case Mode = 3 OTHERlist = *concat_lines(OTHERlist,cLine) 'other stuff we don't process just allow user to edit end select next '---------------------------------------- '// determine file that actually exist -- '---------------------------------------- DBFlist = sortsubstr(DBFlist,crlf()) 'sort the list of files for each Line in DBFlist cLine = Line - "" 'Forced Line value into a character value from pointer value IF file.exists(cLine) 'does the file listed actually exist DBFsel = *concat_lines(DBFsel,cLine) 'yes add to selected list else DBFnoExist = *concat_lines(DBFnoExist,cLine) 'no add it to a list for debugging and counting end if next CntNoExist = line_count(DBFnoExist) 'number of DBF & DDD files that will be removed IF ("f" $ Debug) 'debugging stuff to verify we parsed correctly Trace.WriteLn(*concat_lines("-- DBF Files START --",DBFlist,"-- DBF Files END --")) end if IF ("o" $ Debug) Trace.WriteLn(*concat_lines("-- Other Stuff START --",OTHERlist,"-- Other Stuff END --")) end if IF ("n" $ Debug) Trace.WriteLn(*concat_lines("-- DBF Not existing START --",DBFnoExist,"-- DBF Not existing END --")) end if '------------------------- '// DBF List for Dialog -- '------------------------- DIM Format as p 'format for dbf names Format.tab_stops="" Format.odd_row_color="White" Format.even_row_color="Blue White" Format.odd_selected_color="Dark Blue" Format.even_selected_color="Dark Blue" Format.font="Arial,8" Format.font_color_unselected="Black" Format.font_color_selected="White" Format.lastbutton="OK" Format.group_size=1 Format.number_rows=.f. Format.alternating_bands=.t. TempList = a5_owner_draw_list_fmt(DBFlist,Format) 'Format into something for selection dialog DIM aDBFlist[line_count(TempList)] as C aDBFlist.initialize(TempList) '---------------------------- '// Put up the edit dialog -- '---------------------------- DIM Result as C DIM Dialog as C Dialog =<<%dlg% {region} {wrap=75} A script to correct the Alpha5 ADB file.; This file contains the list of tables in the database.; Sometimes the file list tables that actually no longer exits.; This will cause errors in database compact operations and can affect shadow operations.; {endregion}; {line=1,0}; {region} {wrap=75} Select Tables to place in ADB. Tables that exist are already checked. Tables that do not exist are NOT checked. You can manually alter the selected tables.; Number of Tables NOT found: [%r%.5CntNoExist]; [%d;O={@@}%.75,20DBFSel^$$aDBFlist]; {endregion}; {region} Other Information, can be edited. Do not alter markers, they are not reproduced.; [%mw%.75,10OtherList] {endregion}; {line=1,0}; {region} <&Save Changes back to ADB file!save> <*&Exit!exit> {endregion}; %dlg% '-- Simple call of dialog -- Result = ui_dlg_box(DialogTtl,Dialog) 'present Dialog if Result <>"save" then 'do we proceed end end if '------------------------ '// Make backup of ADB -- '------------------------ ADBbackup = get_unique_filename(ADBfile) 'get unique backup file name File.Copy(ADBfile,ADBbackup) 'copy existing ADB file to backup file IF .NOT. file.exists(ADBbackup) 'verify backup copy worked ui_msg_box(DialogTtl,"Creation of ADB backup file failed",UI_ATTENTION_SYMBOL+UI_OK) end end if ADBout = *concat_lines(":Files",DBFsel,Otherlist) 'reformat information for new ADB LineOut = line_count(ADBout) 'how many lines in new ADB gives indication of size change IF ("w" $ Debug) 'final debug option to see new file before we write it out Trace.WriteLn(*concat_lines("-- new ADB START --",ADBout,"-- new ADB END --")) else SAVE_ADB_DEF(ADBfile,ADBout) end if 'prepare and present summary message Mess =<<%txt% Updated Alpha5 Database (ADB) file: {ADBfile} Orginal had {LineIn} lines. Now has {LineOut} lines. Orginal Database file backed up to: {ADBbackup} %txt% ui_msg_box(DialogTtl,evaluate_string(Mess),UI_OK) end