Jump to content
Fortitude

Detecting new Line with StringSplit

Recommended Posts

Fortitude

Hello!

I'm making a program with autoIT where i put down a Editbox (with KodaGUI)
and i need to split the input data from that, by newline.
Until now i did the splitting with space ( " " ), but i need to split with newline. tried with  "\n" but didnt work :P
and i'm not sure how to do properly with "@CR or @CRFL or @FL".. I tried to change for these, but its making weird outputs.

Here is my Codepart:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Convert_kivalaszt
            $Edit1_data = GUICtrlRead($Fajlok_edit)
         Case $Convert_button
            Global $Userdata = StringSplit( $Edit1_data, " ")
            
....
..

 

Share this post


Link to post
Share on other sites
Subz

Usually just need to split by @LF, if you copy text into something like NotePad++ and turn on symbols you'll notice the CRLF symbols in the text when there is a new line.

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro

Good morning @Fortitude, and welcome to the AutoIt forum :)

Quote

Until now i did the splitting with space ( " " ), but i need to split with newline.

If you write in your Edit some text, new line, and write some other text, and copy this text and paste to Notepad++ ( for example ), you will notice that at the end of the line, the character @CRLF is added.
So, what you have to do, is something like this:

Local $strReadFromEdit = "This" & @CRLF & "is" & @CRLF & "text", _                                   ; From the Help file about StringSplit():
      $arrReadFromEdit = StringSplit($strReadFromEdit, @CRLF, BitOr($STR_NOCOUNT, $STR_ENTIRESPLIT)) ; Note that the macro @CRLF is actually a 2 character string, so unless the flag
                                                                                                     ; parameter to $STR_ENTIRESPLIT extra blank lines will be generated as the string
                                                                                                     ; is split on both @CR and @LF.
    _ArrayDisplay($arrReadFromEdit)

Always take a look at the Help file before posting something here! :)


Best Regards.


 


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

ALWAYS GOOD TO READ:

In case I am violating some pseudo Forum rule, or I am doing something wrong, I want let you know that I'm not doing this on purpose, and for this, I kindly ask you to send me a private message about the "bad content" I posted, in order to edit/remove it, and to not be warned wrongly.
Thanks in advance.

 

Share this post


Link to post
Share on other sites
Fortitude

Thank you guys for help, my problem is solved.


I did check the Help, but could'nt figure out what's wrog, now all clear. :)

 

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

×