Code archives/File Utilities/Comment Box Generator

This code has been declared by its author to be Public Domain code.

Download source code

Comment Box Generator by Baystep Productions2008
This wonderful doozy generates nice neat blitz comment boxes from inputed text files. Just run it through, select the input and output files and the character to build walls from.

On your input files just place "+separator+" on its own line to add a wall separator.

SIDE NOTE: Code archives messed up the comment spacing on the beginning example/legal it works much cleaner when executed.
;////////////////////////////////////////////////////////////////
;//READ ME - (this was also generated by this program!)        //
;////////////////////////////////////////////////////////////////
;//Basicly....                                                 //
;//Save what you want commented in a txt file. Use the phrase  //
;//"+seperator+" on its own line to add a break in the comment //
;//box. Then supply an output file name. Choose 1 character to //
;//build the comment walls from. And let it go! Then copy the  //
;//output files contents and paste them in your code.          //
;//                     ENJOY ITS FREE - CHRIS PIKUL           //
;////////////////////////////////////////////////////////////////

Graphics 500,300,16,2
AppTitle "Build Me A Comment!"
Global inp_info$=Input("Text file to be commented: ")
Global out_info$=Input("Output B3D file for copy paste: ")
Global opt_char$=Left(Input("Character to build walls with: "),1)
Global wall$ = opt_char$+opt_char$
Type inline
	Field txt$
End Type
Global iln.inline
Type outline
	Field txt$
End Type
Global oln.outLine

file=ReadFile(inp_info$)
If Not file Then RuntimeError("Could not read input source!")
Print "Reading input file..."
Delay (500)
While Not Eof(file)
	iln.inline = New inline
	iln\txt$ = ReadLine(file)
Wend
CloseFile(file)

Print "Building statistics..."
Delay (500)
Global max_width%=0
For iln.inLine = Each inLine
	Local tmp_width%=Len(iln\txt$)
	If tmp_width%>max_width% Then max_width%=tmp_width%
Next

Print "Generating comments to memory..."
Delay (500)
oln.outLine=New outLine
oln\txt$=String$(opt_char$,max_width%+4)
For iln.inLine = Each inLine
	If Trim(Lower(iln\txt$))="+separator+"
		oln.outLine=New outLine
		oln\txt$=String$(opt_char$,max_width%+4)
	Else
		If Len(iln\txt$)<max_width
			iln\txt$=iln\txt$+String(" ",max_width-Len(iln\txt$))
		EndIf
		oln.outLine=New outLine
		oln\txt$=wall$+iln\txt$+wall$
	EndIf
Next
oln.outLine=New outLine
oln\txt$=String$(opt_char$,max_width%+4)

Print "Outputing saved comments..."
Delay (500)
file=WriteFile(out_info$)
For oln.outLine = Each outLine
	WriteLine(file,";"+oln\txt$)
Next
CloseFile(file)

Print "Finished! (closing in 3 seconds)"
Delay (3000)
End

Comments

Ryan Burnside2008
Please include and executable for those without blitzbasic.


Ryan Burnside2008
Disregard the last post. I thought I was in the projects section.


Code Archives Forum