Jump to content

Remove Trailing Spaces


Recommended Posts

I wrote a script that would take data from edit boxes in my works proprietary program and put it into an Excel spreadsheets, that we use as delivery paperwork. I got it to pull data and put it into cells just fine except for one small problem, there is a set limit that can be typed in the boxes and it takes the info plus all the blank spaces after it. This only gives me a problem in one spot, there are two edit boxes for location, one for city and one for state. Here's a snippet of my code that inputs the data into a cell in Excel.

Send($LocationCity)
Send(", ")
Send($LocationST)

But when it grabs the data for the city it takes what is typed in and all the set space available in the box (a limit of 20 characters) so I end up with an output of something like

San Jose             , CA

(it was removing the extra spaces in my example automagically)

Is there a way to get rid of the extra spaces at the end of the string I store the city data in so the comma will be next to the city name like it should be?

Link to comment
Share on other sites

  • Developers

Is there a way to get rid of the extra spaces at the end of the string I store the city data in so the comma will be next to the city name like it should be?

StringStripWs() ?

:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

StringStripWs() ?

:)

Just be sure to use 3 as a flag to allow for spaces within the city name (ex: Kansas City).

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Hahaha, thank you very much, worked perfectly. :)

I knew there had to be an easy way to do this but seeing as how this is only the second script I've ever written in AutoIt I'm not familiar with all the functions yet.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...