blumi Posted February 8, 2011 Share Posted February 8, 2011 I have a GUI with a GUICtrlCreateEdit Box. There I want to insert a String (copy paste) and edit the string when I click on a button. The strings consits of some lines. To edit the String I want to read it line for line. I can't find a function like readline or similar. (cause I don't know the name) How to realize this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2011 Moderators Share Posted February 8, 2011 blumi,Use GUICtrlRead to get the contents of the Edit and then StringSplit to break it into lines. If your Edit wordwraps we might have to get more complicated and use ControlCommand, but try the above first. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
blumi Posted February 8, 2011 Author Share Posted February 8, 2011 StringSplit sounds good, I will try. Thank you M23 Link to comment Share on other sites More sharing options...
Coxx16 Posted August 6, 2015 Share Posted August 6, 2015 Hi Guys,I know that this is a horribly old thread and I'm not attempting to revive it, but I ran across it while attempting to solve the same problem. I guess I will add my response in the event that someone else needs help with the same issue. Basically, I made an edit box that a user can add text into. At which point, after pressing the button; the program will format each line. I attempted to use the SplitString command, but found that it was difficult to separate the lines if the text had no clear delimiters. ( Please keep in mind that I am newish to programming and very new to Autoit. There may be some elegant way of accomplishing this task.) Here is how I accomplished the task (pseudo-code):Func LineReadGuiCtrlEdit: $mainGuiEdit ; this will represent the variable used to create the edit box $inputString = guictrlread($mainGuiEdit) ; note that if the user entered 5 lines of text, they will be passed to the variable with the line breaks included $outString = " " ; this string will hold the formatted output data Create a temp text file Open temp text file filewrite(temptTextFile, $inputString ) ; writes the data from the edit box into the temp file $fileArray = FileReadToArray(tempTextFile) ; reads the text placed into the For $i = 0 to UBound($fileArray) ; this loop will iterate through each element of the array IF $i < UBound($fileArray) Then ;only execute the following commands as long as you are within bounds of the array IF $fileArray [$i] = "Some condition" Then $outString &= manipulate the line in the current array element End if EndIF $outString &= @CRLF ; In my program I used this in order to keep the original line structure entered by the user. You many not want to however. next ; indicates the end of the for loop return $outString ; you can now use the output of the function and place it in a msgbox or perhaps into a permanent file etc....EndFunc Addendum: Since each element of the array is an individual line of text from the edit box. I don't have to worry about figuring out what would make an appropriate delimiter. If there is a more elegant way of doing this with the SplitString command, I would like to know it for my own edification! Thanks! Link to comment Share on other sites More sharing options...
jvds Posted August 6, 2015 Share Posted August 6, 2015 (edited) Hi, welcome to the forumyou don't need to open an old thread like this, just create a new post then reference the old post, also use the <> to post codeyou could use a unicode chr to split the items i guess, like example below #include <Array.au3> FileWrite('test.txt',"somedata"&chrw(65000)) FileWrite('test.txt',"somedata line1"&@lf&'somedataline2'&chrw(65000)) FileWrite('test.txt',"somedata with line breaks line1"&@crlf&"line2"&@crlf&'line 3'&chrw(65000)) FileWrite('test.txt',"somedata with line breaks line1"&@crlf&"line2"&@crlf&'line 3'&chrw(65000)) $text = FileRead("test.txt") $text = StringSplit ($text,chrw(65000)) for $x=0 to $text[0] ConsoleWrite($text[$x]&@crlf&@crlf) Next _ArrayDisplay($text) ;FileDelete('test.txt') Edited August 6, 2015 by jvds Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now