Monday, October 16, 2017

VFP's Weird File Naming Rules

Visual FoxPro was written for Windows, which is a filename case-insensitive operating system. So, startup.PRG and startup.prg are the same thing. However, there's a lot of inconsistency in how VFP names files:

  • If you don't specify the extension in the MODIFY command when you edit a file, edited files end up with uppercased extensions. For example, for files named form1.scx and form1.sct, MODIFY FORM form1 results in files named form1.SCX and form1.SCT when you save.

  • If you do specify the extension in the MODIFY command, the extension of the main file is set to whatever you specify and the extension of the memo file is uppercased. For example, for files named form1.scx and form1.sct, MODIFY FORM form1.scx results in files named form1.scx and form1.SCT when you save. If instead you specify MODIFY FORM form1.SCX, you end up with form1.SCX and form1.SCT.

  • The MODIFY command also respects the specified case of the stem name. For example, for files named form1.scx and form1.sct, MODIFY FORM Form1.scx results in files named Form1.scx and Form1.SCT.

  • The extension rules don't apply to VCT files: their extension doesn't change when a class is saved; if it was lowercase before, it's still lowercase after.

  • The extension rules are different for tables. The DBF extension doesn't change case when the table structure is changed or records added, modified, or deleted, or the table packed. CDX files are created with an uppercased extension but if you rename it to a lowercased extension, it isn't changed back to uppercase when you change the index structure, add, modify, or delete records, or PACK or REINDEX the table. FPT files are also created with an uppercased extension but if you rename it to a lowercased extension, it isn't changed back to uppercase when you add, modify, or delete records, or PACK the table. However, it is changed back to FPT if you modify the structure of the table.

Why is this important? Because if you use Git, you may have problems when VFP renames a file behind your back because Git is case-sensitive for filenames. Fortunately, it can be configured to be case-insensitive by executing these commands from a Command or PowerShell window:

git config --global core.ignorecase true
git config --system core.ignorecase true

Here's do a little experiment in VFP to test the case-insensitivity:

md c:\testcase
cd c:\testcase modify command startup.prg && enter some text, save, and close ! git init ! git add startup.prg ! git commit -m "Initial commit" modify command startup && notice no extension specified: when change text, save,
&&and close, file is renamed to startup.PRG ! git status --porcelain > status.txt modify file status && shows that startup.prg has been modified ! git commit startup.prg -m "Saved changes" ! git status --porcelain > status.txt modify file status && shows that startup.prg is no longer modified

Tuesday, October 03, 2017

New VFPX Project: Project Explorer

Project Explorer is a new VFPX project that replaces the VFP Project Manager with a modern interface and modern capabilities. It has most of the features of the Project Manager but adds integration with DVCS (including built-in support for FoxBin2PRG and optional auto-commit after changes), support for multiple projects within a “solution,” allows you to organize your items by keyword or other criteria, and has support for easy “auto-registering” addins that can customize the appearance and behavior of the tool. It includes extensive documentation.

I’m presenting sessions on Project Explorer at both Southwest Fox 2017 and German DevCon 2017.

I’m looking forward to feedback on this project. Please create issues for any problems you experience or any suggestions you have for improvements.