Jump to content

Restarting the program


Recommended Posts

Hi Everyone

Long time no post as I found all th eanswers I have needed up to now.

I am running an array against data, when the data is found I _ArrayDelete that value from my SET array

example

At the top of my script I have this

Local $0to10array [10] = [0,1,2,3,4,5,6,7,8,9,10]

I run the script and it brings back an 8, the

$remove = _ArraySearch($0to10array,$thenumber)

_ArrayDelete($0to10array, $remove)

This all works perfect, all I need to know/do is stop the error at the end when the array has only 2 items left.

At the moment I am just using

If UBound($0to10array)-1 > 2 Then

do the work

Else

Exit

EndIf

Is there anyway, instead of just exiting and having to reopen the program, to reload the script so the array is back to how it was on launch?

Link to comment
Share on other sites

  • Moderators

Phaser,

I think does what you want: :mellow:

#include <Array.au3>

While 1

    Global $0to10array[11] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

        _ArrayDisplay($0to10array, "Initial")

    Do

        $thenumber = Random(0, 10, 1)

        $remove = _ArraySearch($0to10array,$thenumber)
        _ArrayDelete($0to10array, $remove)

        _ArrayDisplay($0to10array, "In loop" )

    Until UBound($0to10array) = 1

WEnd

Note that you need 11 elements for your $0to10array. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Hi Pain

Yes I want to re-populate the original array

example

At start

Local $0to10array [10] = [0,1,2,3,4,5,6,7,8,9,10]

After the work

Local $0to10array [10] = [2,8]

exit/rerun the whole thing

Local $0to10array [10] = [0,1,2,3,4,5,6,7,8,9,10]

How do I re-populate it?

Thanks

Link to comment
Share on other sites

  • Moderators

Phaser,

I just told you. Look up a bit! :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Melba23 your script works fine but as always I can't get it working with my setup, it's pointless putting all my code here as it wont run for anyone else, here's what I have

Func whatnumbers()

$a = $a +1

If $a = 1 Then

    $b = 0
    while $b <= 1
        $sum = Eval($0to10array[0] & "x")
        $sum2 = Eval($0to10array[0] & "y")
        ControlClick("window name", "", "", "left", 1, $sum, $sum2 )
        _ArrayDelete($0to10array, 0)
    $b = $b +1
    WEnd

    $remove = _ArraySearch($0to10array,$thenumber)
    _ArrayDelete($0to10array, $remove)

ElseIf $a = 2 Then
    
    $b = 0
    while $b <= 1
        $sum = Eval($11to20array[0] & "x")
        $sum2 = Eval($11to20array[0] & "y")
        ControlClick("window name", "", "", "left", 1, $sum, $sum2 )
        _ArrayDelete($11to20array, 0)
    $b = $b +1
    WEnd

    $remove = _ArraySearch($11to20array,$thenumber)
    _ArrayDelete($11to20array, $remove)

    $a = 0
EndIf

EndFunc

It basically cycles through each array and (currently) exits when they are empty, as you know I wish to re-populate them both when there's only one left in EITHER of them, any ideas?

Link to comment
Share on other sites

  • Moderators

Phaser,

This code works in theory, but I have not run it as there are a number of points I want to raise first:

1. Do you realise the 2 arrays are unequal in size (0To10 is 11 elements, 11To20 is only 10).

2. Where does the $thenumber variable come from?

3. How are you intending to get out of the function? Is there an end-state or does it run indefinitely (which is what it will do at the moment)? :mellow:

#include <Array.au3>

whatnumbers()

Func whatnumbers()

    While 1
        
        ; Declare arrays
        Local $0to10array[11] = [......]
        Local $11to20array[10] = [......]

        ; Keep going until one of them has only 1 element left
        Do

            $a = $a + 1

            If $a = 1 Then

                $b = 0
                While $b <= 1
                    $sum = Eval($0to10array[0] & "x")
                    $sum2 = Eval($0to10array[0] & "y")
                    ControlClick("window name", "", "", "left", 1, $sum, $sum2)
                    _ArrayDelete($0to10array, 0)
                    $b = $b + 1
                WEnd

                $remove = _ArraySearch($0to10array, $thenumber)
                _ArrayDelete($0to10array, $remove)

            ElseIf $a = 2 Then

                $b = 0
                While $b <= 1
                    $sum = Eval($11to20array[0] & "x")
                    $sum2 = Eval($11to20array[0] & "y")
                    ControlClick("window name", "", "", "left", 1, $sum, $sum2)
                    _ArrayDelete($11to20array, 0)
                    $b = $b + 1
                WEnd

                $remove = _ArraySearch($11to20array, $thenumber)
                _ArrayDelete($11to20array, $remove)

                $a = 0
            EndIf

        ; This is where we check if either array has just the one element left
        Until UBound($0to10array) = 1 Or UBound($11to20array) = 1
        ; Now go and reinitialise the arrays

    WEnd

EndFunc   ;==>whatnumbers

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...