Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing a Database 1

Status
Not open for further replies.

gmattox

Programmer
Nov 5, 2001
15
US
Hey,
I want to remove a database & free the tables. THis portion works fine. My problem is when I go to the forms using the now free tables he says he can't find the database. Then he wants to 'Locate' or 'Ignore' the database. If I 'Ignore' he removes all the tables from the form. I have got several forms with 20 to 25 tables each, all with different property settings so I don't want to have to re-add all of these tables.
Anyone got a way to do this with removing all the tables?
Thanks,
Gary
 
Hi Gary.

Anyone got a way to do this with removing all the tables?

Untested and off the top of my head, so you will have to work out the bugs. Make sure you have all of your forms under Source Control ( or at least backed up somewhere ) before you try this:

Code:
LOCAL lcProperties, lnProps, lnI, laProperties[ 1 ]
SET EXACT OFF
USE MyForm.scx IN 0
SELECT MyForm
SCAN FOR LOWER( ALLTRIM( Class ) ) == [cursor]
  lcProperties = []
  lnProps = ALINES(  laProperties, ALLTRIM( Properties ), 1 )
  FOR lnI = 1 to lnProps
    IF LOWER( laProperties[ lnI ] ) # [database]
      lcProperties = lcProperties + ALLTRIM( laProperties[ lnI ] ) + CHR( 13 ) + CHR( 10 )
    ENDIF
  ENDFOR
  REPLACE Properties WITH lcProperties  
ENDSCAN

You could even call this code from a program that uses ADIR() to get a list of all the forms in your forms folder and iterate throught hat array and pass the name of the form to the method ( name it RemoveDatabase ) above like so (also off the top of my head and untested):

Code:
LOCAL laForms[ 1 ]
CD Form, lnI 
lnFormCnt = ( laforms, [*.scx] )
FOR lnI = 1 TO lnFormCnt
  RemoveDatabase( laForms[ lnI, 1 ]
ENDFOR

Marcia G. Akins
 
Marcia,
THis worked great with just very minor mods. Thanks a lot.
Here is the completed routine for going through all forms in a directory:

LOCAL lcProperties, lnProps, lnI, lnF
LOCAL Array laProperties[ 1 ]
LOCAL laForms[ 1 ], lnF
laProperties = " "
lnProps = 0
lnI = 0
lnF = 0
SET EXACT OFF
CD c:\ssi_software\farmhand\source\forms
lnFormCnt = ADIR(laforms, '*.scx')
FOR lnF = 1 TO lnFormCnt
WsForm = laForms[ lnF, 1 ]
WAIT WsForm WINDOW TIMEOUT 2
USE &WsForm
SCAN FOR LOWER(ALLTRIM(Class)) == [cursor]
lcProperties = []
lnProps = ALINES(laProperties, ALLTRIM(Properties ))
FOR lnI = 1 to lnProps
IF LOWER( laProperties[ lnI ] ) # [database]
lcProperties = lcProperties + ALLTRIM(laProperties[lnI]) + CHR(13) + CHR(10)
ENDIF
ENDFOR
REPLACE Properties WITH lcProperties
ENDSCAN
ENDFOR
MESSAGEBOX("Conversion Is Complete",0,"Remove Databases from Forms")

Thanks Again,
Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top