Sign in to follow this  
Followers 0
billthecreator

deleting strings

3 posts in this topic

#1 ·  Posted (edited)

ok, so i have a system that splits the string into an array:

$array = "This1|This2|That3|That4"

and i also have it so it just shows the number part. ( note: the number part is always different )

it shows in a list:

1

2

3

4

i want to know if i click '3' and delete it from the list box, how can i delete it from the array (That3), with it not being the whole string?

Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites



maybe something like this:

#include <GUIConstants.au3>
#include <Array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 206, 179);, 193, 125)
$Button1 = GUICtrlCreateButton("Display Array", 16, 24, 161, 33, 0)
$Button2 = GUICtrlCreateButton("Delete Array Item", 16, 72, 161, 33, 0)
$Button3 = GUICtrlCreateButton("Say String", 16, 120, 161, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$array_count = InputBox("Array", "How many elements you want in your array?", "4")
if @error then Exit

$string = ""
for $i = 1 to $array_count
    if $string = "" Then
        $string = "This" & $i
    Else
        $string &= "|This" & $i
    EndIf
Next

$string_split = StringSplit($string, "|")
dim $array1[$string_split[0]+1]
for $i = 1 to $string_split[0]
    $array1[$i] = StringTrimLeft($string_split[$i], 4)
Next

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button3
            MsgBox(0, "your string is:", $string)
        case $Button1
            _ArrayDisplay($array1)
        case $Button2
            Local $question = InputBox("Delete Array Item", "Input number of the item you would like to delete", "3")
            if NOT @error Then
                _ArrayDelete($array1, Number($question))
                $string = ""
                for $i = 1 to UBound($array1)-1
                    if $string = "" Then
                        $string = "This" & $array1[$i]
                    Else
                        $string &= "|This" & $array1[$i]
                    EndIf
                Next
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ok, but, really this is for attachments in an email program. i have the shortname of the attached file in the list box, but if you delete it, it just deletes the list data, not the actual array section.

Case $Attach
            $ATTACHFILE = FileOpenDialog("Attach File", "", "All Files (*.*)", 5)
            If @error Then
            Else
                $s_AttachFiles = $ATTACHFILE
                $ATTACHFILE = StringSplit($ATTACHFILE, "|")
                If $ATTACHFILE[0] = 1 Then
                    GUICtrlSetData($AttachList, _GetShortName($ATTACHFILE[1]) & "|")
                    $f_size = $f_size +FileGetSize($ATTACHFILE[1])
                Else
                    For $r = 2 To $ATTACHFILE[0]
                        GUICtrlSetData($AttachList, _GetShortName($ATTACHFILE[$r]) & "|")
                        $f_size = $f_size + FileGetSize($ATTACHFILE[$r])
                    Next
                EndIf
            EndIf
            GUICtrlSetData($File_sizes, Round($f_size/1024) & " KB")
        Case $FileDelete
            _GUICtrlListBox_DeleteString($AttachList, _GUICtrlListBox_GetCurSel($AttachList))
            ;this is where i want to delete the array section.
Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

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