Sign in to follow this  
Followers 0
blumi

Read line GUICtrlCreateEdit

5 posts in this topic

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?

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

StringSplit sounds good, I will try.

Thank you M23

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi, welcome to the forum
you 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 code

you 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 by jvds

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