Sign in to follow this  
Followers 0
exus

Remove Trailing Spaces

6 posts in this topic

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?

Share this post


Link to post
Share on other sites



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() ?

:)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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]

Share this post


Link to post
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.

Share this post


Link to post
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.

RTFM

Share this post


Link to post
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
Sign in to follow this  
Followers 0