visual-foxpro

Can someone help me with VFP pathing and includes?


I've been writing foxpro since 2.6. For the last 15 or 20 years I have used the Visual FoxExpress framework. I guess I am so accostomed to my framework that basic foxpro things are still elusive to me. I am spending weeks struggling with some basic concepts. I am asking for help.

I have a project. The project has many prg's that I have included in the project. When I rebuild my project with the "recompile all" and "show me the errors" features on, sometimes the prg's do not get recompiled. I delete the fxp's and modify the prg by adding a comment to ensure the prg's get recompiled. That seems to work but it appears they do not get compiled because a file named myprogram.err gets created. The VFP compiler does not tell me there were any errors but I do see the myprogram.err file. The first line of executable code in this myprogram.prg is #INCLUDE WCONNECT.H WCONNECT.H is also included in my project under text files. The myprogram.err says "#INCLUDE WCONNECT.H Error in line 4: File does not exist.". I guess my first question is how can an included prg not find wconnect.h if it too is included in the project?

Thanks, John


Solution

  • I was also frustrated by that

    sometimes the prg's do not get recompiled

    issue, so I wrote a small prg (rcompile.prg) to compile all explicity. Since then, I do not trust "Recompile all" and use that rcompile.prg. Here is the code of rcompile.prg:

    Lparameters tcProjectName, tlNonVerbose
    If !Empty(m.tcProjectName) And Type('_vfp.ActiveProject') = 'U'
      Modify Project (m.tcProjectName) Nowait
    Endif
    
    If Type('_vfp.ActiveProject') = 'U'
      Return
    Endif
    Set Notify off
    LOCAL ix,totalFiles
    ix = 0
    totalFiles = 0
    For Each loFile In _vfp.ActiveProject.Files
      If loFile.Type $ 'PKV'
        totalFiles = m.totalFiles + 1
      ENDIF
    endfor
    
    ? 'Total', m.totalFiles
    For Each loFile In _vfp.ActiveProject.Files
      If !m.tlNonVerbose And loFile.Type $ 'PKV'
        ix = m.ix + 1
        ? m.ix, loFile.Name
      Endif
    
      Do Case
        Case loFile.Type = 'P'
          Compile (loFile.Name)
        Case loFile.Type = 'K'
          Compile Form (loFile.Name)
        Case loFile.Type = 'V'
          Compile Classlib (loFile.Name)
          *!*   Case loFile.Type = 'R'
          *!*     Compile Report (loFile.Name)
      ENDCASE
    Endfor
    Set Notify on
    

    You either pass your project's filename to it, or there is an active project open in the project manager.

    I can't answer to second part of the question, it is weird. Instead of trying to find a reason, I would have wconnect.h located in a folder that is in default search path during compilation (and development in general).

    I have this set in my Tools\Options\File Locations\Search path set:

    progs; forms; libs; menus; other; reports; include; bitmaps; datainclude; d:\foxyclasses\classes; d:\vfpcommonclasses
    

    and .H files under Include folder. Having same folder structure with all the projects, this works nicely (and I can test prg, scx etc individually without a recompile all). I almost only compile the whole project just before releasing it.