Jump to content

Multiple lines of text input


Recommended Posts

Hey, I'm writing a program, and I want to make it possible to get multiple lines of input from the user using one textbox. right now I'm just using a InputBox:

$site = InputBox("Whatever", "Input multiple lines of text")

This works great and wonderfully for one line of text. The question is, how do I make it possible to enter multiple lines? I've looked around on the forums and havn't been able to find anything... Something that will read all the lines and store it in an array or something like that. Any suggestions would be very gratefully received.

Thanks!

Link to comment
Share on other sites

If you are set on using a inputbox rather than a gui, you can have the user type in "@CRLF" or "@CR" or any other symbol of your choice, then run a StringReplace() on it, looking for "@CRLF" in the quotes, and replacing it with a @CRLF without the quotes.

Link to comment
Share on other sites

Thanks for your help everyone! I'll put my code here in case someone else has the same question in the future...

#include <GUIConstants.au3>

    GUICreate("Site Submission") 

    Opt("GUICoordMode", 1)

    $Button_1 = GUICtrlCreateButton("ok", 10, 30, 100)

    $Button_2 = GUICtrlCreateButton("cancel", 0, -1)
    $myedit = GUICtrlCreateEdit("Enter url's here", 50, 50, 300, 150, $ES_AUTOVSCROLL + $WS_VSCROLL + $es_wantreturn)

    GUICtrlSetPos($Button_1, 10, 10, 70)
    GUICtrlSetPos($Button_2, 80, 10, 70)
    GUISetState()   ; will display the box with 2 buttons and the textarea

; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                ExitLoop
            Case $msg = $Button_2
                Exit
        EndSelect
    WEnd
    
    $sites = GUICtrlRead($myedit)
    $lines = StringSplit($sites, @CRLF)

With this they can type or paste whatever they want into the box, and then the array $lines has all the lines in it.

Edit:typos :-)

Edited by FitzChivalry
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...