×
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

How to explicitly include a free DBF table by code using the BUILD PROJECT command
2

How to explicitly include a free DBF table by code using the BUILD PROJECT command

How to explicitly include a free DBF table by code using the BUILD PROJECT command

(OP)
Is there any way to include a DBF file in the project by code? When you add a free table in your project that file will be excluded by default so you must to include it explicitly if you want to use it within your EXE.

Here's an example of BUILD PROJECT command:

CODE --> vfp

lcPJXFileName = "c:\path\to\my\project.pjx"
Text To lcBuildCommand Noshow TextMerge Pretext 7
Build Project <<lcPJXFileName>> From ;
"foo.prg", ;
"bar.dbf"
EndText =ExecScript(lcBuildCommand)

Now you may build your app:

CODE --> vfp

If File(lcPJXFileName)
lcAPPFileName = "c:\path\to\myApp.app"
Build App (lcAPPFileName) From (lcPJXFileName)
Endif

If you use your "bar.dbf" you get a "File does not exists" message because bar.dbf was excluded implicitly when issue the BUILD PROJECT command.

Any idea how to achieve this?

regards!

A team is only pieces that you exchange until you finish the work, it is efficient, it works.

RE: How to explicitly include a free DBF table by code using the BUILD PROJECT command

(OP)
If there isn't any way to achieve this by hand so I'll have to do this:

CODE --> vfp

If File(lcPJXFileName)
Use (lcPJXFileName) Alias MyProj In 0
Update MyProj Set Exclude = .F. Where "bar.dbf" == JustFname(name)
Endif

A team is only pieces that you exchange until you finish the work, it is efficient, it works.

RE: How to explicitly include a free DBF table by code using the BUILD PROJECT command

I don't see a way to do that in the BUILD PROJECT command on the help.
Nothing in the way of intellisense help either.

I think I would add that update code after you build the project, but I would be tempted to be a bit more selective in the update.

CODE

lcAPPFileName = "c:\path\to\myApp.app"
lcPJXFileName = "c:\path\to\my\project.pjx"
Text To lcBuildCommand Noshow TextMerge Pretext 7
Build Project <<lcPJXFileName>> From ;
"foo.prg", ;
"bar.dbf"
EndText
=ExecScript(lcBuildCommand) 
If File(lcPJXFileName)
  Select 0
  Use (lcPJXFileName) Alias MyProj
  Locate for "BAR.DBF"$UPPER(MyProj.Name) .and. Type="D"
  if Found()
    replace Exclude with .f.
    use
    Build App (lcAPPFileName) From (lcPJXFileName)
  else
    MessageBox("NO BAR.DBF FOUND in Project",48,"Problem")
    use
  endif
Endif 

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: How to explicitly include a free DBF table by code using the BUILD PROJECT command

There is a way:

CODE

For Each loFile In _vfp.ActiveProject.Files
   If Lower(Justfname(loFile.Name)) = "your.dbf"
      loFile.Exclude = .F.
   Endif
Endfor 

Starting from scratch first open the project, obviously:

CODE

Close All
Modify Project ("c:\path\to\your.pjx") Nowait 

What's neat with this is that Modify Project also offers a NoShow clause, so you could become the invisible project manager. Besides that, you could use a project hook that overrides the default for DBF files when a QueryAddFile event happens. This is less elegant though, as you only have the filename as parameter and the file is not yet part of the project, so all you could do is note down this dbf needs to be included. Later with a build do so, or in other events, or with a timer...Convoluted, overcomplicated ways are always possible.

So after all, the method to set the exclude column in the PJX table is not the worst. It's all the official way of acting on project and file object does anyway. The Project and ProjectHook classes offer a lot of possibilities to keep in mind.

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! Already a Member? Login

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