Jump to content

Strange output in Array, STringSplit


Recommended Posts

im getting strange output in array display,$split_[1] is not properly aligned to other arrays and why guictrlsetdata is not writting any data if i put comma(,) at the end of the text in $Input1???

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#Region ### START Koda GUI section ### Form=C:\Users\user\Desktop\Script\StringSplit.kxf
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Input1 = GUICtrlCreateInput("50UGITQ421X, 50UGITQ422X, 50UGITQ423X, 50UGITQ427X, 50UGITQ431X, 50UGITQ435X, 50UGITQ436X, 50UGITQ437X, 50UGITQ441X, 50UGITQ445X, 50UGITQ449X, 50UGITQ453X, 50UGITQ454X, 50UGITQ455X, 50UGITQ459X", 24, 16, 553, 21)
$Split = GUICtrlCreateButton("Split", 24, 48, 75, 25)
$List1 = GUICtrlCreateList("", 24, 96, 553, 97)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Split
            $read = GUICtrlRead($Input1)
            $split_ = StringSplit($read, ",")
            $Max = UBound($split_, 1)
            For $i = 1 To UBound($split_) - 1
                ConsoleWrite($split_[$i] & @CRLF)
;~              ControlSetText($Form1, "", $List1, $split_[$i])
                GUICtrlSetData($List1, $split_[$i])
;~              GUICtrlSetData($List1, $split_[$i])
;~              GUICtrlSetData($List1, $i)
            Next
            _ArrayDisplay($split_)
    EndSwitch
WEnd

 

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

$Split[1] looks different than the other entries because it doesn't have a space in front of it like the other entries.

 

Edit: As for your other problem, try this line of code:

If $split_[$i] <> "" Then GUICtrlSetData($List1, $split_[$i])

If you put a comma at the end of the Input, StringSplitwill create an empty array entry. If the loop uses GUICtrlSetData with an empty string, the entire List gets deleted.

Edited by Floops
Link to comment
Share on other sites

20 minutes ago, Floops said:

GUICtrlSetData with an empty string, the entire List get's deleted

thats why im getting empty data, got empty string in $split_[16] :lol:

 

20 minutes ago, Floops said:

$split_[1] looks different

what do you mean looks different? it has the same no. of characters. also in $List1 its not aligned

just asking not really my " other problem " :P:P:P

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

As Floops mentioned: "1, 2, 3" isn't the same as "1,2,3", so you need to either place a space before 1 like so " 1, 2, 3" or remove all spaces from the string, before you split.

Edit: Floops already responded

Edited by Subz
Link to comment
Share on other sites

oh shoot, now I understand both your explanation, I will keep in mind these space. :sweating::sweating::sweating:

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

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

×
×
  • Create New...