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!

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

Status
Not open for further replies.

Irwin1985

Programmer
Feb 2, 2017
44
ES
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:
lcPJXFileName = "c:\path\to\my\project.pjx"
Text To lcBuildCommand Noshow TextMerge Pretext 7
[indent]Build Project <<lcPJXFileName>> From ;[/indent]
[indent]"foo.prg", ;[/indent]
[indent][b]"bar.dbf"[/b][/indent]
EndText
=ExecScript(lcBuildCommand)

Now you may build your app:

Code:
If File(lcPJXFileName)
[indent]lcAPPFileName = "c:\path\to\myApp.app"[/indent]
[indent]Build App (lcAPPFileName) From (lcPJXFileName)[/indent]
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.
 
If there isn't any way to achieve this by hand so I'll have to do this:

Code:
If File(lcPJXFileName)
[indent]Use (lcPJXFileName) Alias MyProj In 0[/indent]
[indent]Update MyProj Set Exclude = .F. Where "bar.dbf" == JustFname(name)[/indent]
Endif


A team is only pieces that you exchange until you finish the work, it is efficient, it works.
 
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 [Smile]ing

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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top