Menu

Attached: Patch which fixes JCF IDE Plugins to be installable under current JCL/JVCL

Developers
2024-04-14
2024-04-15
  • Mark A Paley

    Mark A Paley - 2024-04-14

    Introduction

    Jedi Code Format (JCF) is an indispensable tool for Pascal programmers, by standardizing the layout of program code. Consistently formatted source code is much easier to read and comprehend.

    Terrifically, JCF is automatically included when installing the Lazarus or CodeTyphon Integrated Development Environment (IDE).

    It's a huge shame that JCF isn't included with any version of Delphi (probably due to licensing reasons). It's also mind-boggling that JCF hasn't been used to standardize the entire source code for Lazarus, FreePascal, or Delphi themselves.

    However, the current JCF version 2.43 fails to install as a Delphi IDE plugin, because it is dependent upon the Jedi Visual Code Library (JVCL), and the current JVCL version 3.49 (which itself requires current version JCL 2.7) no longer matches JCF 2.43.


    Example of the first of many Fatal Errors encountered when trying to install the IDE plugin.

    Patched

    I have patched the JCF source code to now correctly install inside the Delphi IDE. I have tested this patch against the Delphi 7 and Delphi 2009 (D12) IDEs, and assume that it will work with the others corrected here, as well.

    A complete list of the 37 files which have been patched.

    If you want to see each and every code patch performed (and you are a true glutton for punishment), then open the file "JCF243-Patched-To-JVCL349.patch" in a text editor or browser.

    However, following is an overall summary describing the corrections which have been made:

    Matched the new names of the required JCL files

    Matched the new name of the required JCL files.

    Added Required Directories to Package Search Path

    Added the Required directories to the package Search Path.

    Removed incompatible unneeded EXPLICIT properties from dfm files

    Removed incompatible and unnecessary EXPLICIT properties from all dfm files.

    JCF now actually looks for its Settings configuration file

    Originally, JCF incorrectly looked for it's configuration file within Delphi's "Bin" folder (circled in red), even though that's not where JCF installed it.

    After patching, if the settings file field is blank (or if the settings file doesn't actually exist at the location stated in that field), then JCF will actually search for, and set this field to, the first location where it finds the "JCFSettings.cfg" file.

    This location will differ, depending upon which version of Delphi is installed, or which version of Windows (32 vs. 64-bit) it is installed upon (hence the need to actually search for this file).

    Now it's correctly set.

    To speed up the one-time search for this file, the patch first looks for "JCFSetting.cfg" within "C:\Program Files". If not found there, then it looks within "C:\Program Files (x86)".

    If still not found, then it looks to wherever "GetCurrentDir" is pointing. My guess is that this might handle situations where JCF installed to some drive other than "C:", but I haven't actually tested that (only so many hours in a day).

    Finally, as a last-ditch resort, it searches the entire "C:\" drive for the file.

    In the worst case scenario, a user can just manually type in the correct location (just as the current non-patched version requires now).

    How to Install

    It would be very nice if JCF had its own semi-automatic installation program, just as JVCL does -- or if it were simply incorporated into JVCL's current installer (hinty, hint, hint...).

    However...

    • First, install whichever version of Delphi you own.
    • Create a new folder for the Project Jedi files.
    • Then, manually create a new "JCF" sub-folder.

    This Delphi 2009 example shows manually creating a "Jedi" folder inside the "C:\Program Files\CodeGear\RAD Studio\6.0" folder.

    This Delphi 7 example shows creating a "Jedi" folder, and "JCF" sub-folder, inside the "C:\Program Files\Borland\Delphi7" folder.

    The patch assumes that JCF will be in a folder alongside JCL (see image above).

    Copying JCF source files to the JCF folder.

    • Apply the Patch simply by unzipping the files from "JCF243-Patched-To-JVCL349.zip" on top of and overwriting the original source files which you already previously put in the "JCF" folder.

    Applying the patch files.

    • Click "Yes to All"
    • Congratulations, now you're "patched."

    • Navigate to the "jcl" folder, and click on the "Install.bat" file.

    • Agree to the license.

    Don't blow past the next tab without first looking at the BPL Path line (circled in red above).

    This tab may (or may not) show the correct BPL path.

    If it says "\Bpl" in red letters, then you'll want to manually correct this. Open a Command Prompt, type "path", look for the Bpl path (here, "C:\Documents and Settings\All Users\Documents\RAD Studio\6.0\Bpl"). Either navigate to that folder, or just type it in manually.

    Here the BPL path is correct.

    • Click the Install button.
    • Click Yes to Install All Features.

    • Navigate to the JVCL folder, and select "Install.bat".

    I recommend checking the box for "Build packages"

    Within Delphi, open the IDEPlugin package matching your version of Delphi.

    • Run your version of Delphi
    • File Close All
    • File Open, change Files of type to "Delphi package (.dpk; .dpkw)"
    • Navigate to the IdePlugin folder for your version of Delphi (here
      D12 is also known as Delphi 2009).

    • Open the dpk package file

    • Right-click on the matching BPL file shown in the right-hand pane,
      then select Install

    • Early versions of Delphi (here, Delphi 7) instead show a much more
      obvious "Install" Button.

    After a moment, an Information popup will say that JCF installed successfully.

    "JEDI Code Format" now appears on the Tools menu.

    "About JEDI Code Format" shows that JCF is working in Delphi 2009.

    Delphi 7 shows a correct JCF installation.

    "JEDI Code Format" now appears on the Tools menu in Delphi 7.

    "About JEDI Code Format" page shows that JCF is working in Delphi 7.

    Closing

    The PDF version of this file contains "JCF243-Patched-To-JVCL349.patch"

    and "JCF243-Patched-To-JVCL349.zip" as savable attachments.


    Mark A. Paley (see https://gitlab.com/MarkAPaley/filey).

     

    Last edit: Mark A Paley 2024-04-15
  • Anthony Steele

    Anthony Steele - 2024-04-15

    Wow, it has been a long time since i looked at this codebase. I am not in a position to take active ownership of it.

    I am open to suggestions for how people who use it can maintain it - should it be forked, or maintainers added? Is SourceForge still the appropriate venue?

     
    • Mark A Paley

      Mark A Paley - 2024-04-15

      Hi Anthony,

      I'd need to give some serious thought to your questions before I could give a you an intelligent response.

      On mere first impression, it would make sense for the "JCL people" to maintain JCF, since JCF needs to be updated periodically to reflect its dependencies upon periodic updates made to JCL. (Including JCF within JCL's installer would be a great bonus.) However, I'd completely understand if they consider JCF to be outside their wheelhouse. They also probably have a lot on their plate already.

      What I can tell you without hesitation is this:

      • JCF inside the IDE (as opposed to running standalone) is so useful while physically writing code that it is by-far the strongest factor pulling me toward open-source IDEs like Lazarus, which have JCF built-in.

      • I'd prefer to use Delphi itself, rather than its open-source cousins, but JCF no longer working inside Delphi's IDE was a big push away from Delphi (hence my reason for patching JCF to restore that capability).

      • My preference for Delphi is probably somewhat unique -- I simply like working with dBase DBF files.

        • DBF is simple, fast, flexibile, and doesn't require the painful overhead exhibited by every other database solution out there.

        • Years ago I purchased the outstanding Delphi TOPAZ library, which provides wonderful DBF support within Delphi, but is not compatible with non-Delphi pascal.

        • The open-source TDbf component is a very good effort, but has nowhere near the capabilities of TOPAZ, and is an insufficient DBF substitute for my needs. (TDbf also needs significant improvement in Filtering, indexing, speed, memory leaks, and most especially Documentation.)

      • In a perfect world, I'd love to see JCF also incorporate the code Sort and Rearrange ability of the free (but not open-source) MMX ModelMaker Code Explorer.

        • This feature physically re-arranges code-blocks of functions, procedures, and variables into alphabetic order.

        • This allows a programmer to create code in whatever order he needs while writing, and then instantly re-organize the code into a consistent manner.

      • It seems that JCF already does such a big chunk of the code dissection needed to accomplish such a feat, that JCF is just crying out for this feature to be added.

      • I am unaware of any other software which provides this feature (not even Visual Code Studio).

      • Even if MMX ever became open-source (unlikely), it would still need to be updated to Delphi language extensions which post-date it.

        • For example, it is beyond irritating that MMX strips off very-efficient Initialization of variable declarations (it changes "var i: integer = 0;" into "var i: integer;"), because that wasn't a part of the Delphi language when MMX was written. Stripping this forces adding an undesired "i:= 0;" line later in the code. Multiply this times nearly every variable in a program.

        • MMX's many other complicated features do not interest me (so there's less that would need to be duplicated into JCF).

      • It is simply dumbfounding that neither Borland, CodeGear, nor Embarcadero included a professionally-written official version of this Sort and Rearrange feature into Delphi itself.

      Respectfully,

      -- Mark A. Paley

       

      Last edit: Mark A Paley 2024-04-15

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.