Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
REM Line Remover!!!
#1
Smile 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 ('$INCLUDESmile'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!! Big Grin

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... Big Grin
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)

[Image: 11895-r.png]
Reply
#2
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!"
Reply
#3
All hail the code obfuscator! Big Grin

I'd rather have a program which did just the contrary.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
Good idea! A program adding random rem lines would be a good obfuscator too....Big Grin
Antoni
Reply
#5
Or one that adds comments :o
Reply
#6
: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.. Smile
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#7
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.
Reply
#8
Smile 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)

[Image: 11895-r.png]
Reply
#9
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
Reply
#10
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]
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)