forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


"Remove leading/trailing spaces" utility...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Feb 17, 2003 1:26 pm    Post subject: "Remove leading/trailing spaces" utility... Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon Feb 17, 2003 1:30 pm    Post subject: Reply with quote

Good thing to have in the toolbox. It works nicely in VDS 4.50. Very Happy
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Feb 17, 2003 1:38 pm    Post subject: Reply with quote

Thanks for checking it FF. Smile
_________________
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
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group