Converting PJX > PJ2 > PJX Removes .SetMain("xxx.prg") #115
Replies: 10 comments 2 replies
|
Here is the output of AI review. Bug Analysis: Converting PJX > PJ2 > PJX Removes .SetMain() (#115)ReproductionPure round-trip with no manual editing:
Occurs when the PJX's HomeDir (from the original developer's machine) is on a different drive than where the user runs foxbin2prg. Root Cause: Format Mismatch Between .ADD() and .SetMain()The Two Different Formats
.ADD('<<loReg.NAME>>')Produces:
.SetMain(<<THIS.GetPathFromHome(m.loProject._MainProg, m.lcStr, "lcCurdir + '", "'", m.toFoxBin2Prg)>>)What GetPathFromHome Does (line 18891)lcReturn = SYS(2014, m.tcFilePath, m.tcProjPath)
Do Case
Case m.toFoxBin2Prg.n_CheckFileInPath=2 AND !EMPTY(JUSTDRIVE(m.lcReturn))
lcReturn = '"' + m.tcFilePath + '"' && double-quoted format
Otherwise
lcReturn = m.tcPrefix + m.tcFilePath + m.tcSufix && lcCurdir + 'file' format
Endcase
The Hardcoded n_CheckFileInPath (line 18413)toFoxBin2Prg.n_CheckFileInPath=2This is hardcoded to The Failure TraceStep 1: PJX -> PJ2PJX HomeDir =
PJ2 output: Step 2: PJ2 -> PJXParsing
Writing PJX (line 13168): lcMainProg = Lower(Sys(2014, toProject._MainProg, Addbs(toProject._HomeDir)))
= Lower(Sys(2014, 'source\sdt.prg', 'D:\dev\project\'))
Comparison (line 13236): , (loFile._Name == lcMainProg) ;
Step 3: PJX -> PJ2
Why It Works on the Original Developer's MachineOn the original machine, current dir and HomeDir are on the same drive:
Suggested FixOption A: Skip SYS(2014) for relative paths (line 13168)If If Empty(JustDrive(toProject._MainProg))
lcMainProg = Lower(toProject._MainProg)
Else
lcMainProg = Lower(Sys(2014, toProject._MainProg, Addbs(toProject._HomeDir)))
EndifOption B: Don't use GetPathFromHome for SetMain (line 18626)Use the same bare-filename format as If Not Empty(loProject._MainProg)
TEXT TO C_FB2PRG_CODE ADDITIVE TEXTMERGE NOSHOW FLAGS 1+2 PRETEXT 1+2
<<>> .SetMain(lcCurdir + '<<loProject._MainProg>>')
ENDTEXT
EndifThis matches the original commented-out code at line 18624. Option C: Remove the hardcoded n_CheckFileInPath (line 18413)The hardcoded Files to ChangeOnly one file:
|
|
Oops. This one came never to my knowledge. I get no notification on discussions. It should have been an issue. I will create an issue pointing here. Guess who has done some alterations now. I try to understand the problem and add the fixes later on. |
|
I had this problem too when importing projects, but it was with my refactoring codebase. But if set to not write Homedir in the pj2 , setmain works normally HomeDir: 0 && Home Directory in PJX And I confirm the problem occured in only in pj2 files without the lcCurdir in the .SetMain() line. |
|
@ccantrell72. What happens if you create the pjx from the pj2 from the repo? At least with my comp "source\sdt.prg" is Mainprog. The HomePath is still wrong - until I open the pjx with the IDE. That fixes this. The way you used FoxBin2Prg (see Reproduction above) - not opening the PJX first with VFP IDE - transforms a PJX with information that will not fit to it's storage location. This is not really a bug, it's just the second step of an algorithm in front of the first. FoxBin2Prg is bound to believe that the PJX is where the PJX belongs. FoxBin2Prg does the most possible to CD next to the PJX to have recent path there. It assumes PJX HomeDir equals the Path of the PJX, at least on the Bin2Text process. TextBin runs flawless with strange HomeDir, as it should. I think, your Option B might be a solution - possibly I have misunderstood this while adding the support of additional drives. I do not fully understand the implications of this, but I think I go back to the old code and deal with issues if they raise. Option C: #128 This is something left over from a test, I remove this. |
|
Update: |
|
@ccantrell72 , @DougHennig, @lkmatsumura I need some input. I tested around with project's HomeDir Property. The help on HomeDir is:
Creating a test scenario I played around with this, like setting HomeDir some folders away and on a location on different drive. I can not confirm that the storage of files in the PJX (Name field) is in any way relative to HomeDir. It's just all the time relative to the path of the PJX file. Has anybody some insight what HomeDir is doing? Or used it at all? I created an issue VFPX/HelpFile#51, so we can alter the help here ... So, basically, the whole idea of GetPathFromHome, and the like, setting some stuff relative to HomeDir looks like the wrong approach. It must be relative to the pjx. |
|
I have HomeDir = 0 in my config file because I cannot think of what circumstances you would want to save and restore it. Because it is unlikely two developers would have the project in the same drive and folder, the PJ2 file would always be different if it included HomeDir. I believe you are correct that HomeDir is the folder the PJX is located in. I think it is used as the relative path for files in the PJX but cannot confirm that. |
|
Sorry, I meant I have HomeDir = 0 now. Back when I created sdt.pj2, I must not have. Maybe Option B is the solution? |
|
@ccantrell72 @DougHennig You might test FoxBin2prg.prg with #119 I now run this on pjx directory, not HomeDir. There are some new options to CheckFileInPath, see https://github.com/lscheffler/foxbin2prg/blob/fork_mod/docs/FoxBin2Prg_Settings.md#configuration-file. |
|
I think you described the issue very well. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reproduced with the following
Downloaded ZIP of https://github.com/DougHennig/StonefieldDatabaseToolkit. Unzipped
Windows Explorer - Right Click - Send To - PJX to PJ2 File
Opened in Text Editor - Set Main there.
Right Click - Send To - PJ2 to PJX
Right Click - Send to - PJX to PJ2
Set Main removed - verified in Project viewer the main PRG is no longer set.
FYI - never opened any files with FP. Just converting 2 to bin and bin to 2.
All reactions