Posts: 2,404
Threads: 153
Joined: Jan 2005
 Realesing this as source, very compact..
What it does:
Removes un-used lines in a proggram. REMs and whitespaces
Reduces size of program (if there is anything to remove)
Leaves ('$INCLUDE  's alone and unharmed..
Keeps a backup, or you can make it overwrite a file (Not Recomended, anything can happen).. :wink:
What it doesn't
PRINT "Hello" 'Remove a REM on the side of a line
Example:
Took Rlesoft's Julia Rings
From : 224 Lines of code..
To: 175 Lines of code..
And it still worked!!
Minus the "SLEEP 100" it should run in QB also.. Or for faster speeds, just for looks.. speed is good either way.. :wink:
Here it is...
Code: PRINT "REM Line Remover 1000!"
PRINT
PRINT "No worries, checks for '$INCLUDE:, so that want be erased ;)"
PRINT
INPUT "File Name:(add extention also)", file$
INPUT "Resave REM free as:(add extention)", file2$
OPEN file$ FOR INPUT AS #1
OPEN file2$ FOR OUTPUT AS #2
DO
IF EOF(1) THEN EXIT DO
LINE INPUT #1, lineread$
IF MID$(UCASE$(lineread$), 1, 4) = "'$IN" THEN GOTO writelib
IF MID$(lineread$, 1, 1) = "'" THEN GOTO skipwrite
writelib:
IF lineread$ = "" THEN GOTO skipwrite
PRINT #2, lineread$
PRINT "Line Cept:", lineread$
SLEEP 100 'REMOVE this For more speed!
skipwrite:
LOOP
CLS
PRINT "All done! :D"
SLEEP
Enjoy!!!!
Kevin ( x.t.r.GRAPHICS)
Posts: 242
Threads: 29
Joined: Dec 2004
Why would you want to do this?
It will not effect the final compiled program and removing any programmer comments and white space (lines) would make the source harder to read.
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Posts: 6,419
Threads: 74
Joined: Mar 2002
All hail the code obfuscator!
I'd rather have a program which did just the contrary.
Posts: 1,407
Threads: 117
Joined: Dec 2002
Good idea! A program adding random rem lines would be a good obfuscator too....
Antoni
Posts: 251
Threads: 22
Joined: Dec 2004
Or one that adds comments :o
Posts: 2,404
Threads: 153
Joined: Jan 2005
:lol: Finialy I manage the comments I expected!!!! *Runs and jumps for joy*
Just something simple I wanted to play with, and, If I ever get the time, I was planning to make one that added remlines (comments on funtions used)..
:wink: And, just in case of the event that your proggy passes 2gigs (thats FB's limit right?) You can crunch it with this, he he, most unlikly tho it can happen.. :lol: :rotfl:
Edit: it should also double for QB where space is needed most, and alows you to comment and order your proggy w/o the worry of removing 'em yorself in the end.. :wink: .. But I did this in FB, the FBIDE is more colorful, and I can focus better..
Kevin ( x.t.r.GRAPHICS)
Posts: 254
Threads: 8
Joined: Apr 2005
How would you write a program that added any meaningful comments, as the program wouldn't know what the different variables mean, etc. The most you could do to this line:
LET A=2
would be 'make A equal 2
IMO you could not make a program that would tell the person reading the source any more than he already knew, not without a lot of work anyway.
Posts: 2,404
Threads: 153
Joined: Jan 2005
 Eh, what in the case a learning programmer (noob) wanted a lil more info on the proggy he/she was looking at.. e.i. it be for standard statement like:
Code: LINE (0,0)-(300,200)
PRINT "Hello"
I'd make it scan an input something like this:
Code: 'This is the LINE statement. It draws a line on the screen to givin vectors..
LINE 90,0)-(300,200)
'This is the PRINT statement. It displays givin text to the screen..
PRINT "Hello"
Probaly in a little more detialed,. Just a example.. I'd mostly not bother with LETing varibles,.. unless I made a debbuger on their values.. :wink:
Kevin ( x.t.r.GRAPHICS)
Posts: 251
Threads: 22
Joined: Dec 2004
Quote:fsw Wrote:Or one that adds comments :o
How would you write a program that added any meaningful comments, as the program wouldn't know what the different variables mean, etc. The most you could do to this line:
LET A=2
would be 'make A equal 2
IMO you could not make a program that would tell the person reading the source any more than he already knew, not without a lot of work anyway.
It was a joke...
Sorry, should have placed this :rotfl:
instead of this :o
Posts: 72
Threads: 11
Joined: Feb 2005
One more example
[syntax="qbasic"]
'-- ******************************************'
sub DelComments (STxt$ as string)
'delete comments in SrcTxt$
'function tally - see http://forum.qbasicnews.com/viewtopic.php?t=8787
' qt as string =chr$(34)
NQT=tally(STxt$, qt)
PQT1=0
PQT2=0
PRem=0
for i=0 to NQT+1
PQT1=instr(PQT2+1,STxt$, qt)
if PQT1=0 and PQT2>0 then ' no quotes yet
i=NQT+1
else
PQT2=instr(PQT1+1,STxt$, qt)
end if
'PQT2=instr(PQT1+1,STxt$, qt)
PRem=instr(PRem+1,STxt$, "'")
if (PRem < PQT1 and PRem >0) or (PQT1=0 and PRem >0) then
STxt$=left$(STxt$,PRem-1)
'print"2STxt$=";STxt$
exit for
else
PRem=PQT2
end if
next
end sub '
'-- *****************************************'
[/syntax]
|