AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can I get a loop, parse to ignore or delete blank lines?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Hedonist



Joined: 24 Jan 2005
Posts: 34

PostPosted: Mon Jul 07, 2008 6:31 pm    Post subject: How can I get a loop, parse to ignore or delete blank lines? Reply with quote

I am trying to get data from a gui edit box then input a common value at the beginning of every line. The problem I have is that each entry ends with a carriage return, so I end up with a blank line at the end of my list.

Like this.
    server1
    server2
    server3
    -->blank line<--


Her is my code.
Code:
GuiControlGet,servers,,Edit1,
loop, parse, servers, `n, `r
  newservers .= "`n" grid "," a_loopfield ","


This is what I get.
    grid1,server1,
    grid1,server2,
    grid1,server3,
    grid1,,


This is what I want.
    grid1,server1,
    grid1,server2,
    grid1,server3,


How can I get it to ignore or delete a blank line?
Back to top
View user's profile Send private message
Hedonist



Joined: 24 Jan 2005
Posts: 34

PostPosted: Mon Jul 07, 2008 8:27 pm    Post subject: Reply with quote

Any help?

At this point I would settle for editing the string. I thought I could do it with StringReplace, but I can't figure it out.
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Mon Jul 07, 2008 8:29 pm    Post subject: Reply with quote

you should wait at least a day before bumping your topic. This community is still small enough that there is not always an expert/helper logged in.

Code:

GuiControlGet,servers,,Edit1,
loop, parse, servers, `n, `r
  If (A_LoopField)
    newservers .= "`n" grid "," a_loopfield ","


untested
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Hedonist



Joined: 24 Jan 2005
Posts: 34

PostPosted: Mon Jul 07, 2008 9:23 pm    Post subject: Reply with quote

Got it thanks to member SKAN.

Code:
GuiControlGet,servers,,Edit1,
loop, parse, servers, `n, `r
{
  ifequal,a_loopfield,, continue
  newservers .= (( A_Index = 1 ) ? "" : "`n" ) grid "," a_loopfield ","
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group