×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Copying a free table between projects

Copying a free table between projects

Copying a free table between projects

(OP)
A project test1.pjx has a free table in it (Project manager | Data | Free tables). I would like to copy that table structure and all its data (ten records) into another project Test2.pjx.

How can I do that, please?

RE: Copying a free table between projects

You copy the table files, then add this copy to the test2.pjx. There's no dependency of a DBC, that's what makes it a free DBF.

So what's your problem?

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Copying a free table between projects

Copying the table and adding it to a project are two separate steps.

Use a simple COPY TO command to copy the table. This will copy the structure and its data.

Then add the new table to the project in the usual way. For example, from the Project Manager (Data / Free Tables / Add) or by dragging it from a Windows folder into the Project Manager.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Copying a free table between projects

I don't think COPY TO will include any structural index files, unless you include the WITH CDX clause

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: Copying a free table between projects

I don't know why you'd want to do such a thing programmatically at all. If that's the goal, you should tell so, Andrew, because that's adding two or more levels of difficulty. If not, copying a table and adding it to another project is as simple as the two steps I and Mike already told about.

Do you look for a programmatic solution, do you want this as a feature for some self-programmed project manager?

If so, the main piece of the puzzle is not how you copy files - I don't believe that you don't know any way to copy files, even if you'd use DOS commands. Choose one of COPY TO, COPY FILE, STRTOFILE(FILETOSTR()) or FCREATE/FOPEN/FRITE/FCLOSE.

You can automate the project manager(s) and use aproject.Files.Add() to add a file to a project. Where aproject has to be a project object. The simplest one is _vfp.ActiveProject, but of course test2.pjx might also be another than the active project. So you need to find which project of _vfp.Projects is your target project test2.pjx.

And the next level of problem is, you don't have that at runtime, only within IDE. But let me stop at this point, I still don't get what the real problem is. Do you really not know a table is just a set of files you can copy as any other files? Or how you add anything to a project? Or that a free DBF really is just standalone it's 1-3 files (in special cases more idx or cdx, but let's not go down that rabbit hole). I don't understand what problem you could have at all. Copying files and adding a file to a PJX are very basic steps of vfp source code project "management".

The common question as always: What did you try and what did not work?

Easy ways to shoot into your own foot is having the table in question open exclusvely.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Copying a free table between projects

(OP)
Thanks Mike.

Have copied the underlying .dbf file into the ‘test2.pjx’ folder ; then opened the test2 project and Added that table to the list of free tables - along the lines you suggested; that does it.

RE: Copying a free table between projects

If you just want to do this manually, then what did hinder you?

You don't need to copy the file inside VFP to stay valid, you can also use Windows Explorer, Total Commander or any other favorite file handling tool and copy the dbf/fpt/cdx files, then add the copy to the second pjx, as I said in short: You copy the table files (step 1), then add this copy to the test2.pjx (step 2).

I'm still really interested to know what wasn't clear for you about that?

I can only imagine you were sitting in front of two VFP sessions or one with both projects open and wondered how you could do that with drag&drop. If you try that you see you don't get a copy but let the other project point to the same DBF file.

I'd really like to know what puzzles you and what you don't get.

On a side note, VFPs way of having a pair or triple of files for a thing that is represented as one project item makes it a less good candidate for source control like using Team Foundation Server or Github, but still you just need to copy files, you can even copy a whole project folder with all it's contents to keep the current version as is and continue development from there in another folder. The only dialog you get when opening the project copy is whether the new folder should be the new home folder and that's it. Then your yourapp.pjx in the new /yourapp version2/ folder will be totally independent of the old pjx and whenever you need to revert back because a change didn't work, you have all the old versions of anything.

From that perspective, you can also emulate many features of a source code version control just for the price a new branch means a lot of file copies Github would not need to create unless you really change anything in a new branch of work.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Copying a free table between projects

(OP)
Olaf

I am creating a new project which requires the same free table as one specified in an old project under Data| Free tables.

It was a question of whether it would be sufficient to drag the table from the old project and drop it onto the new project or whether it was necessary to copy the .dbf file itself and then (as a separate operation) Add it to the new project.

I have the answer I require, thank you, and have chosen the second option – of copying the .dbf file itself.

RE: Copying a free table between projects

Aha,

thanks for pointing that question out now, you never stated it originally. As I said and tested a drag&drop will let the new project point back to the same file, you therefor "inherit" that data and once it's changed in the old project it's changed for your project, too. VFP allows references to files outside a projects home folder and that way you can really share common things, that update for every project they are used in.

It's seldom something you want and while it sounds fancy, most often you'll just be surprised what doesn't work in an older project you come back to, just because common libs changed. Or just some records of a free table. So in that sense, I second your choice of copying the DBF.

You can see that yourself, the project manager has a status bar showing you the path and file name of a project item:

You easily spot when a file you look at would point back to the older myproject1 folder.

The situation you describe is a typical setup of a follow-up project or a new version of a software, where you can simply work on a full copy of the whole project folder, don't start off with an empty folder and PJX and add back what you need the cumbersome way, item by item.

What you can do for adding is drag & drop, but not from an old project to new project, from a Windows Explorer folder. Copy over the files you want to reuse in your 2nd project, create a new empty PJX, if you absolutely want to restart that way and then drag&drop from the file copies into the project manager to add a bunch of files in one go. That's also a well-known comfort mechanism.

For example, you might want to reuse libraries but nothing else: Then Copy over the libs folder of your old project with all vcx,vct,vcx files, create a new PJX and drag&drop from the copied libs folder into the empty project manager of the new PJX. You now have the same set of libs, momentarily. But whatever you change for your new project won't affect the old project, this now has become a separate branch of your libs development. If you drag&drop from the original project folder you will instead share the libs and have that inheritance with all its pros and cons.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close