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 

Simple Question: Working with new lines in a script

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Conquer-NLI
Guest





PostPosted: Fri Mar 19, 2010 12:32 am    Post subject: Simple Question: Working with new lines in a script Reply with quote

Hello there, I'm trying to first count the number of lines in a GUI edit control, and then replace the topmost line if there is over 6 lines.

Here is my code:

Code:
 
gui,submit,nohide
stringreplace,test,status,`r`n,,A
  result := errorlevel
  if result > 6    ; more than 6 lines, out of space, erase the top line
  {
    parsing := status
    status =
    pastfirstline = false
    loop, parse, status             
    {
      if a_loopfield = `n
        pastfirstline = true
      if pastfirstline = true
        status .= a_loopfield
    }
  }


The problem is that the script doesn't seem to recognize `r`n as a new line (so the result is never higher than 6), if I check the script's variable debugger, the result seems to be 0 found each time. I've tried lots of things in place of `r`n but can't seem to get it to work.
Back to top
OceanMachine



Joined: 15 Oct 2007
Posts: 780
Location: England

PostPosted: Fri Mar 19, 2010 12:41 am    Post subject: Reply with quote

Are you sure there is actually a new line character that you are looking for in your Edit control? A normal multi-line edit control will wrap text onto multiple lines, even if there are no newline characters at all in it...

How/why are you limiting to 6 lines (are you trying to for the text to fit on your gui or something like that?)
Back to top
View user's profile Send private message
NLI-Conquer
Guest





PostPosted: Fri Mar 19, 2010 12:47 am    Post subject: Reply with quote

Nvm I figured it out. I was missing the "UseErrorLevel" switch in the last parameter. And yeah its so I can fit the right amount of messages into a small edit control.

Thanks sin_tax
Back to top
sin_tax
Guest





PostPosted: Fri Mar 19, 2010 3:23 am    Post subject: Reply with quote

Cool
Back to top
Display posts from previous:   
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