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!

script to restructure table under DOS 1

Status
Not open for further replies.

Levi_imported

IS-IT--Management
Oct 26, 2000
24
GB
Hi All,

Shot in the dark, but i hope one of you can help.

I am supporting a legacy system using Paradox 4.0 (DOS) databases. Because they are being accessed by multiple clients over a network they frequently get corrupted. I know how to repair the tables (TUTILITY followed by reindex / restructure using PARADOX) but I would REALLY like to be able to automate as much of this as possible.

I have been able to automate the tutility part of the equation so i can issue a command rather than going through all of the menus, but I am unable to do the same for the paradox portion as I do not know how to write paradox scripts!

Is it possible to write a script that tells the paradox program to:

1.) choose the 'tools' menu
2.) choose 'copy' and then 'just family'
3.) provide the table names (live and backup)
4.) choose 'modify', 'restructure' and then provide a table name.

If anyone can help (a few pointers, a summary of script writing, a fully working script ;-) ) I would be VERY grateful
 
Yes, it's been awhile, but if I remember correctly it is relatively simple.

{tools}{copy}{justfamily}

SELECT tablename.db

SELECT OK (this part I might be misremembering)

SELECT othertable.db

SELECT OK (maybe)

That's from memory. Let me see if I happen to have any old code laying around that I can use to verify any of this.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Okay here is one that I tested to make sure it works:

{tools}{copy}{justfamily}
SELECT "tablename" ;(without the extention)
SELECT "tablename2"
SELECT "Copy"
SELECT "Replace"



Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Thanks Mac!!!!! You have just made my life sooooooooo much easier!

So is the {command} notation how you describe selecting a menu option from within paradox 4 scripts?
 
For the restructure it would be similar.

{modify}{restructure}
SELECT "tablename" ;(without the extention)

use commands LEFT RIGHT UP DOWN to navigate,
to type text, just put it in quotes "newField"

For example: to change the first fieldname to "Test"
and set is as a alpha string of size 50.

{modify}{restructure}
SELECT "tablename"
RIGHT
CTRLBACKSPACE ;(to remove the original fieldname)
"Test"
RIGHT
CTRLBACKSPACE
"A50"
{DO_IT!}

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Yes, the brackets{} denote a dropdown menu choice.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Mac,

Just need one last piece of help... how the heck do you get the script to instruct paradox to quit one it has finished??????? The script runs on my test system (and does everything I need it to - cheers!) but once it has completed paradox does not quit to the command prompt.

Should the end of the script be...

{exit}
SELECT "yes"

...which doesn't seem to do anything, or should it quit automatically and I am just having a problem with my test system?

Thanks in advance...
 
Nope, just the key word EXIT on the last line. (no quotes) Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Levi,

I don't have a copy of Paradox/DOS installed at work, so I'm guessing, but I *think* you might try adding

Code:
clearall

above your call to exit. (I confess my memory may still be caffeine deprived, as I just poured my first cup of coffee.) There may be an open image on the workspace and that may be preventing the exit.

Hope this helps...

-- Lance
 
Try this on a nightly run through the task scheduler.

;******************************************************
message " Exporting data... "
{tools}{Exportimport}{Export}{ascii}{delimited}{table1}{table1}
if menuchoice() = "Cancel" then
{Replace}
endif
{tools}{Exportimport}{Export}{ascii}{delimited}{table2}{table2}
if menuchoice() = "Cancel" then
{Replace}
endif
{tools}{Exportimport}{Export}{ascii}{delimited}{table3}{table3}
if menuchoice() = "Cancel" then
{Replace}
endif

message " Restructuring tables... "
Empty "table1"
Empty "table2"
Empty "table3"

{modify}{restructure}{table1} do_it! clearall
{modify}{restructure}{table2} do_it! clearall
{modify}{restructure}{table3} do_it! clearall

message " Inserting records... "
{tools}{Exportimport}{Import}{ascii}{appenddelimited}{table1}{table1}{newentries} clearall
{tools}{Exportimport}{Import}{ascii}{appenddelimited}{table2}{table2}{newentries} clearall
{tools}{Exportimport}{Import}{ascii}{appenddelimited}{table3}{table3}{newentries} clearall

message " Applying indexes... "
INDEX MAINTAINED table1 ON "Indexname1"
INDEX MAINTAINED table1 ON "Indexname2"
INDEX MAINTAINED table1 ON "Indexname3"
INDEX MAINTAINED table2 ON "Indexname1"
INDEX MAINTAINED table2 ON "Indexname2"
INDEX MAINTAINED table3 ON "Indexname1"
INDEX MAINTAINED table3 ON "Indexname2"

message " Done! "
Exit
;*********************************************

A word about this, don't run this only when there are problems with the databases. Run nightly to prevent long lasting corruption. If there are problems with the database do this manually to guard against an invalid export of the data. Also do a directory copy of every file in this directory to another drive, just in case something happens, power-wise, and nothing finishes.

I have found this to be very helpfull in preventing huge data problems over the long run. Very few times needed to rebuild everything from scratch. Also keeps the database tight and clean. Not to mention faster.

Another technique you can try. Is to have duplicate tables on the side. For instance, having t1, t2 and t3 tables with the same structures and instead of emptying the current tables, delete them and copy t1 to table1, t2 to table2, etc... and then import the data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top