Giter Club home page Giter Club logo

beautify's People

Contributors

doughennig avatar stevenblack avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

beautify's Issues

Manually call beautify.prg

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 	

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.