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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find all files used in compilation 5

Status
Not open for further replies.

Vince Wen

Programmer
Jun 15, 2024
7
HK
This could be very simple but I am new to VFP9.

I inherited this legacy software that compiles and works fine. But it has a lot of folders and files built up over the years that are not used. I want to get rid of all the unused files so I have a clean slate to start with.

Is there a way to find out what are all the files used in the compilation process? Such that I can delete everything not used?
 
One thing you can surely and easily refactor with exprerssíons rather than replacing the current with the next year number. Beause both SQL FROM clasue and the USE command can be used with macro substitution or name expression.

For example
Code:
USE Sales_2024
claerly only works this year and
Code:
USE Sales_2025
only next year but
Code:
USE ("Sales_"+STR(Year(Date()),4))

Just don't get the idea to remove the outmost brackets, this is called name expression and while
Code:
? "Sales_"+STR(Year(Date()),4))
also outputs the same string as
Code:
? ("Sales_"+STR(Year(Date()),4))
Within the USE command the outer brackets make clear that the name (of the table/file to open) is an expression, and thus can be an expression involving functions like YEAR(), too. You just need to ensure the whole expression results in the name you need.

So finally replace
Code:
USE Sales_2024
with
Code:
USE ("Sales_"+STR(Year(Date()),4))
And you never need to replace it again.

Programming that way you never need to touch parts of the code again.

If you need to extend CASE statements by a new year and very specific code for that, this can't be generalizued, but that's normal application maintenance, isn't it? Anytime you have hardcoded a year that just needs to be replaced by the next number, that's just bad progreamming style, no matter in what programming language. You also don't need another programming language to have a feature like YEAR or incrmenting a number. If you need previous and next year -1 and +1 are included in the VFP language, too. [tongue]

So the yearly adaptions to the next year are reduced to the actually non-automatibale places. Not doing that is neither good thinking of the original programming nor of the adaption procedure you do each year.

Chriss
 
dogchow01 said:
not sure if MODIFY STRUCTURE is something that can be automated

Mike Lewis already told you it can be done and I agree. I'll tell you how I do it:
I have a metadatatable where all tables are listed with both the DBF-Structure, the CDX-structure and other data regarding every table in the system.
I never USE a table directly, it always goes thru an OPEN()-function which as its first parameter is the name of the table, then there are parameters how to open it i.e. EXCLUSIVE, READONLY, IN 0, and what index to use etc.

When new columns are needed I add them to the DBF-structure and change a field called DBFTRIG which is used to see if the DBF needs to be rebuilt, like this "!FIELD(FCOUNT())='ADRID'". In this case, if the last field isn't ADRID, the DBF should be rebuilt. One could use other triggers like this one: "FSIZE('kunaxorg')<>25"

I have similar techniques regarding CDX-structure and triggers to change them.

Also there's a field called AfterDBFbuild where I can run some actions AFTER the rebuild.

PS. dogchow01, it's common courtesy here to use a real name, just so you know 😂
 
Just want to go back to your original question. I've written a little set of tools for playing with what's in a project and it has the ability to tell you what files in your folder structure aren't part of the project. I've written about it a couple of times; one that includes the code for download is The download ink for that paper is on this page:
Tamar
 
Dan Olsson said:
dogchow01, it's common courtesy here to use a real name, just so you know

That's right. If you glance at any of the recent threads, you will see that all the regulars here now post under their real names. As well as being a courtesy, it means that we have a friendly way of addressing each other.

To adjust the name that appears in your posts, go to My Stuff > My Profile (in the top right of the screen) and edit the name that appears as Display Name. This won't affect the name the you use to log in; that is the User Name.

If you have a good reason for wanting to keep your real name secret, by all means use a nickname, but please choose a sensible name rather than what appears to be a random string of lower case letters.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top