Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Feb 17, 2003 1:26 pm Post subject: "Remove leading/trailing spaces" utility... |
|
|
Sometimes when I save a web page as text, things are indented
half way across the page. I threw this together to remove any
amount of spaces I choose - so I can preserve some indentation,
or remove it all.
It only edits clipboard contents - you must copy the offending
text first, run the program, then paste the results. Also, it only
removes spaces, so it shouldn't remove any chars if you enter
more spaces than exists.
In the edit boxes, you can:
1. Use numbers
2. Use the word "ALL"
3. Leave one of them blank (or both if using the checkbox)
There is no error checking for invalid entries except "greater
than zero".
It can remove different numbers of leading and trailing spaces
in a single pass. The checkbox takes precedence if checked.
Not sure how it will display on your system - wasn't originally
planning on posting it...
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Code: |
rem -- removes leading and/or trailing spaces --
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Remove Spaces",-1,0,190,140
DIALOG ADD,BUTTON,Remove,5,125,60,22
DIALOG ADD,TEXT,T0,28,125,60,30,"Use 'ALL' or a number..."
DIALOG ADD,TEXT,T1,9,5,,,"Leading spaces"
DIALOG ADD,EDIT,E1,5,85,30,22
DIALOG ADD,TEXT,T2,34,5,,,"Trailing spaces"
DIALOG ADD,EDIT,E2,30,85,30,22
DIALOG ADD,CHECK,CK1,55,5,,,"Remove all leading and trailing"
DIALOG ADD,TEXT,T3,65,5,180,55,"______________________________"@cr()"Removes x number of spaces (if that"@cr()"many exist) from each line of clipboard"@cr()"contents - OR remove all spaces."
DIALOG ADD,STATUS,Stat,"Ready..."
DIALOG SHOW
LIST CREATE, 1
:EVLOOP
DIALOG SET, Stat, "Ready..."
WAIT EVENT
goto @event()
:RemoveBUTTON
if @dlgtext(E1)@dlgtext(E2)@dlgtext(CK1)
else
WARN "Enter number of leading and/or trailing spaces to remove, or check 'Remove all...'."@cr()@cr()"You can use the word 'ALL' or a number in edit boxes."@cr()@cr()"'Remove all...' takes precedence if checked."
goto EVLOOP
end
DIALOG SET, Stat, "Please Wait..."
LIST PASTE, 1
WAIT
if @greater(@count(1), 0)
%x = 0
REPEAT
%s = @item(1, %x)
if @dlgtext(CK1)
%s = @trim(%s)
else
if @equal(@dlgtext(E1), "ALL")
REPEAT
if @equal(@substr(%s, 1), " ")
%s = @strdel(%s, 1)
end
UNTIL @not(@equal(@substr(%s, 1), " ")) @equal(@len(%s), 0)
else
if @greater(@dlgtext(E1), 0)
%n = @dlgtext(E1)
REPEAT
if @equal(@substr(%s, 1), " ")
%s = @strdel(%s, 1)
end
%n = @pred(%n)
UNTIL @greater(1, %n) @not(@equal(@substr(%s, 1), " ")) @equal(@len(%s), 0)
end
end
rem ---------------------------
if @equal(@dlgtext(E2), "ALL")
REPEAT
if @equal(@substr(%s, @len(%s)), " ")
%s = @strdel(%s, @len(%s))
end
UNTIL @not(@equal(@substr(%s, @len(%s)), " ")) @equal(@len(%s), 0)
else
if @greater(@dlgtext(E2), 0)
%n = @dlgtext(E2)
REPEAT
if @equal(@substr(%s, @len(%s)), " ")
%s = @strdel(%s, @len(%s))
end
%n = @pred(%n)
UNTIL @greater(1, %n) @not(@equal(@substr(%s, @len(%s)), " ")) @equal(@len(%s), 0)
end
end
end
LIST PUT, 1, %s
%x = @succ(%x)
UNTIL @greater(%x, @pred(@count(1)))
end
LIST COPY, 1
LIST CLEAR, 1
goto EVLOOP
:CLOSE
EXIT
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|