vfpx / beautify Goto Github PK
View Code? Open in Web Editor NEWSpecify capitalization and indentation styles for code (XSource)
License: Other
Specify capitalization and indentation styles for code (XSource)
License: Other
Hello Doug,
I created an Addin in your ProjectsExplorer app for the event BeforeModifyItem
I check if it is a prg file, and if it is, then I open it with notepad++ (or vscode)
But before I give the file to notepad++, I wanted to "beautify" the file. I thought I will call the beautify.prg file - but I could not understand the options parameter
When I STEP though the code during a normal beautify, I see that the options property is filled with some unreadable text
Kindly guide me
For the time being, I am doing the following small hack in the beautify.prg
LPARAMETERS m.inFile, m.options
*m.options is something special and cannot be read by me - nor can we pass it manually. It has to be passed by the Beautify dialog box from the VFP Menu
IF VARTYPE(inFile) = "L"
=MESSAGEBOX("No filename passed to beautify",65,"Beautify Settings")
ENDIF
LOCAL llCalledManually
LOCAL gnFile,gnSize,gnPath
gnPath = JUSTPATH(SYS(16)) &&path of beautify.prg - Store/Retrieve the beautify.settings here
gnPath = ADDBS(gnPath)
IF VARTYPE(options) = "L" or VARTYPE(inFile) = "L"
*This program has been called manually but parameters are missing. I will make use of the
*previously stored beautify.settings
IF !FILE(gnpath+"beautify.settings")
=MESSAGEBOX("Beautify Settings not found"+CHR(13)+CHR(13)+;
"1. Change the file location for Beautify (Tools,Options,File Location) to the beautify.prg which you have downloaded from github.com/VFPX/Beautify/tree/master/beautify"+CHR(13)+CHR(13)+;
"2. Open any prg file and run Beautify from Tools"+CHR(13)+CHR(13)+;
"3. Select your favourite settings and click on Run"+CHR(13)+CHR(13)+;
"This will create the beautify settings file",64,"Beautify Settings")
RETURN
ELSE
gnFile= FOPEN(gnpath+"beautify.settings",12)
gnSize= FSEEK(gnFile, 0, 2)
=FSEEK(gnFile, 0, 0) && Move pointer to BOF
m.options = FREAD(gnFile, gnSize)
=FCLOSE(gnFile)
llCalledManually = .T.
ENDIF
ELSE
*This is being called by the Menu item, so the m.options is properly filled
*store the options parameter in a local file using low level file functions
*I can use this file when I am calling the beautify manually
gnFile = FCREATE(gnpath+"beautify.settings")
=FWRITE(gnFile , m.options)
=FCLOSE(gnFile)
ENDIF
RELEASE gnFile,gnSize,gnPath
and the return has been modifed to
IF llCalledManually
LOCAL oldsafety
IF SET("SAFETY") = "ON"
SET SAFETY OFF
m.oldsafety= "ON"
ELSE
m.oldsafety = "OFF"
ENDIF
SET SAFETY OFF
&&replace the original file with the formatted file
TRY
COPY FILE (retval) TO (infile)
CATCH
=MESSAGEBOX("Could not store the formatted file!. File is open?",64,"Beautify")
ENDTRY
SET SAFETY &oldsafety
RETURN
ELSE
RETURN (m.retVal) && output file name
ENDIF
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.