AronGahagan / cpt-dev

Code repository for the ClearPlan Toolbar
https://www.ClearPlanConsulting.com
3 stars 1 forks source link

Globally add Optional 'Erl' to all calls to cptHandleErr() #51

Closed AronGahagan closed 5 years ago

AronGahagan commented 5 years ago

Request

Globally add optional Erl to all calls to cptHandleErr. If line numbers are enabled, the error message will include the Erl (Error reference line?). If there is no error, then Erl returns 0 and the sub cptHandleErr() will ignore it.

Suggestion

- Call cptHandleErr("cptText_bas", "cptResetRowHeight", err)
+ Call cptHandleErr("cptText_bas", "cptResetRowHeight", err, Erl)

Todo:

AronGahagan commented 5 years ago

Bash/git/grep/sed...incredible. Did this for all .bas, frm, and .cls files in both the root and all subdirectories with a single line of code*:

git grep -l err\) | xargs sed -i 's/err)/err, Erl)/g'

HT: https://blog.jasonmeridth.com/posts/use-git-grep-to-replace-strings-in-files-in-your-git-repository/

todo:

AronGahagan commented 5 years ago

When merging, be sure to ignore whitespace errors (sed created one on every line):

git merge -Xignore-space-change

HT: https://stackoverflow.com/questions/9776527/merging-without-whitespace-conflicts

AronGahagan commented 5 years ago

Celebrated too soon. Evidently running sed with the -i switch (edit inline) messed with the LF vs. CRLF (or something) in the UserForm modules, and VBA no longer recognizes them as forms, tripping an error. Continuing testing.

AronGahagan commented 5 years ago

Tried running git add --renormalize. When using File > Import... from the VBE it appears to work; but running cptUpgrades_frm does not. Used File > Import to pull in the issue51-addErl branch, and the VBE recognized them fine. Then ran my gitVBA export tool, assuming that because VBE recognized them something was 'fixed.' All modules were modified. Then committed and pushed. Then tried to re-run the Upgrades and they still were not recognized.

AronGahagan commented 5 years ago

Everything was fine until I ran the sed -i operation which likely changed line endings. When I added those modified files, I got the CRLF to LF warnings since I have core.autocrlf true. Maybe if I start over from the beginning and set core.autocrlf false it will work.

FMI: https://lostechies.com/keithdahlby/2011/04/06/windows-git-tip-hide-carriage-return-in-diff/

AronGahagan commented 5 years ago

Confirmed: sed -i actually creates a new file and then renames it after the operation completes; which means the Windows line feeds CR+LF are replaced with something unrecognizable by the VBE.

Instead will try perl -pi -e 's/err\)/err, Erl\)/g' and run it against *.bas, *.cls, *.frm */*.bas, */*.frm, */*.cls. Running it with core.autocrlf false. This edits the original file unlike sed -i, and keeps CRLF unchanged. (credit)

...success. All versions bumped and ready to merge into master.

Holding off on merge/push into master until I'm not travelling in case there's a problem.