See if the field ôcalcmethodö exist, add it if necessary.
PSUEDO Code
* This is what the program does.
If [the field does not not exist on the table]
If [able to add the field to the table]
* Add the new field and continue
ELSE
* The field does not exist and unable to add it
* Provide Error Message
ENDIF
ELSE
* Field exists already on table - no action required
* Go On
ENDIF
VISUAL FOXPRO CODE
* I like to add a date check to limit how long the code is executed.
* This is just in case I forget to take it out.
* It prevents unnessary opening / closing of tables over time.
IF DATE() < {08/01/2003}
* The date-check provides plenty of time for the change to occur and stops
* unnecessary opening / closing of tables if another version is not released
* with this code commented out, or I forget to comment out the temporary code.
SELECT 0
USE joblist
AFIELDS(laFields)
IF ASCAN(laFields,"CALCMETHOD") > 0
* the field already exists
* close the table, and go on our merry way
USE
ELSE
* reopen it - this time exclusively so we can modify the structure
USE joblist EXCL
* The USE command closes the table (if necessary) and then tries to reopen it.
* Therefore, the table will not be open if the Exclusive-Use failed, even if
* it were open prior to it.
IF USED('joblist')
* opened exclusively okay
ALTER TABLE joblist ADD COLUMN calcMethod C(4) NOT NULL
* now close it
USE
MESSAGEBOX("Update Successful! - The new CalcMethod field has been " +;
"added...","MyClientName")
ELSE
* Houston, we have a problem.
MESSAGEBOX("Update Failed! - Unable to add the new CalcMethod field " +;
"because the joblist table cannot be opened exclusively at this time. "+;
"Have everyone exit the System and try it again.","MyClientName")
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.