Sign in to follow this  
Followers 0
FitzChivalry

Multiple lines of text input

8 posts in this topic

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!

Share this post


Link to post
Share on other sites



Are you planning on typing or pasting the info into whatever user interface you use? If paste, the just StringSplit ClipGet using @CR ro @CRLF as needed.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I will be pasting, so thanks for the answer! out of curiosity, what would be a good way to do it if I was typing it in?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I would suggest adding a flag to the StringSplit line:

$lines = StringSplit($sites, @CRLF, 1)
For $i = 1 To $lines[0]
    MsgBox(0, "", $lines[$i])
Next


[size="1"][font="Arial"].[u].[/u][/font][/size]

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