Jump to content

Build use and empty an array


Phaser
 Share

Recommended Posts

Hi, my previous thread will probably confuse people even more so I thought I would put the code into a new thread so it can be run, details on what it should do below script code

#include <GUIConstantsEx.au3>
#include <Array.au3>
HotKeySet("{ESC}", "killme")

Local $array[3] = ["0,1,2","1,2,3","2,3,4"]
Local $newarray[10]

$target = 4

while 1 
    it()    
WEnd

Func it()
$i = 0
while $i <= 2
    
    $numarray = StringSplit($array[$i], ",")
    _ArrayDelete($numarray, 0)
    _ArrayPush($newarray,$numarray,1)
    $thenumberarray = _ArrayUnique($newarray)
    _ArrayDelete($thenumberarray, 0)
    _ArrayPop($thenumberarray)
    _ArrayDisplay($thenumberarray)

; check $thenumberarray to see if 4 is in it, if not do nothing

$result = _ArraySearch($thenumberarray, $target, 0, 0, 0, 1)

If $result = -1 Then
    MsgBox(0,"box name", "Not found yet",1);let the $newarray grow
Else
    MsgBox(0,"box name", "Found it",1); empty the $newarray then start refilling it, same routine over and over
EndIf

$i = $i +1
WEnd

EndFunc

Func killme()
    Exit
EndFunc

What am trying to do is populate an array, use its values until something happens then empty it and start the cycle over again.

As you will notice, it builds up until it finds a specific number, 4 in this case, after it finds the number is present I would like it to start from the beginning again, ie 0,1,2 should be the only numbers there, currently it starts with 0,1,2,3 I think the 3 is an actual count, not sure.

I hope someone can see what I am trying to do

Link to comment
Share on other sites

  • Moderators

Phaser,

I have absolutely no idea what you are trying to do, but I think this does what you have described: :graduated:

#include <GUIConstantsEx.au3>
#include <Array.au3>

HotKeySet("{ESC}", "killme")

Global $array[3] = ["0,1,2", "1,2,3", "2,3,4"]
Global $newarray[10]

$target = 4

While 1
    it()
WEnd

Func it()

    For $i = 0 To UBound($array) - 1

        $numarray = StringSplit($array[$i], ",", 2)
        $thenumberarray = _ArrayUnique($numarray)
        _ArrayDelete($thenumberarray, 0)
        _ArrayPush($newarray, $numarray, 1)
        $result = _ArraySearch($thenumberarray, $target)
        If $result = -1 Then
            MsgBox(0, "box name", "Not found yet", 1);let the $newarray grow
            _ArrayDisplay($newarray, "Filling")
        Else
            MsgBox(0, "box name", "Found it", 1); empty the $newarray then start refilling it, same routine over and over
            Global $newarray[10]
            _ArrayDisplay($newarray, "Emptied")
            ExitLoop
        EndIf
    Next

EndFunc   ;==>it

Func killme()
    Exit
EndFunc   ;==>killme

Does it? :(

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

Phaser,

I have absolutely no idea what you are trying to do, but I think this does what you have described: :graduated:

Does it? :(

M23

Hi @Melba ! nice to see you !

How can you think it will do what he has described if you have absolutely no idea what he is trying to do ? Posted Image

Are you medium ? Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Hi @Melba ! nice to see you !

; ...

Are you medium ?

Medium, yes.

Melba was large for a short time, but has been eating right and exercising lately...

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

wakillon,

And bonsoir to you, mon brave. :graduated:

The OP described what he wanted the code to do - and I think it does that. But I have no idea why he wants the code to do it. is that clearer? :D

PsaltyDS,

has been eating right and exercising lately

Always...but with the passing of the years it gets ever more difficult to stay medium... :(

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, my previous thread will probably confuse people even more so I thought I would put the code into a new thread so it can be run, details on what it should do below script code

Erm ... might be a nice idea to put in a note about that in the old topic next time. :graduated:

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

@ MvGulik - sorry about that

Melba, almost, $thenumberarray (with unique values) is the array I want to use, if I change arraydisplay in your code to display $thenumberarray it never goes above 3 values, just before it finds '4' it should have 0,1,2,3

You have arrayunique working on numarray, numarray is only feeding sets of 2 numbers into new array, which could go up to 10 values in total, my thought was use numarray to fill newarray the get unique values from newarray, does that make sense

Link to comment
Share on other sites

  • Moderators

Phaser,

I still have no idea what you are trying to do, but once again I believe this does what you have described: :(

#include <GUIConstantsEx.au3>
#include <Array.au3>

HotKeySet("{ESC}", "killme")

Global $array[3] = ["0,1,2", "1,2,3", "2,3,4"]
Global $newarray[1]

Global $temparray = $newarray

$target = 4

While 1
    it()
WEnd

Func it()

    For $i = 0 To UBound($array) - 1

        $numarray = StringSplit($array[$i], ",", 2)
        If $newarray[0] = "" Then
            $temparray = $numarray
        Else
            _ArrayConcatenate($temparray, $numarray)
        EndIf
        _ArrayDisplay($temparray, "Added")
        $newarray = _ArrayUnique($temparray)
        _ArrayDisplay($newarray, "Unique")
        _ArrayDelete($newarray, 0)

        $result = _ArraySearch($newarray, $target)
        If $result = -1 Then
            ; let the $newarray grow
            _ArrayDisplay($newarray, "Not found yet")
            $temparray = $newarray
        Else
            ; empty the $newarray then start refilling it, same routine over and over
            Global $newarray[1]
            _ArrayDisplay($newarray, "Found it")
            $temparray = $newarray
            ExitLoop
        EndIf
    Next

EndFunc   ;==>it

Func killme()
    Exit
EndFunc   ;==>killme

If this is not what you want, you need to come up with considerably clearer prose to describe what it is you are trying to do. Otherwise I am done trying to produce code for an unknown purpose. :graduated:

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

Phaser,

I still have no idea what you are trying to do, but once again I believe this does what you have described: :(

If this is not what you want, you need to come up with considerably clearer prose to describe what it is you are trying to do. Otherwise I am done trying to produce code for an unknown purpose. :graduated:

M23

@Melba

Are you disappointed or disoriented like your players at Wembley ! Posted Image

Et toc !

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • Moderators

wakillon,

Unlike the donkeys we had on the pitch last night, I am neither "disappointed" nor "disoriented" - just confused over what exactly the OP wants this code to do. :graduated:

Congratulations to France - it looks as if Laurent Blanc has got the basis for a good team there. I would have enjoyed watching them play even more if it had been at someone else's expense. :(

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

wakillon,

Unlike the donkeys we had on the pitch last night, I am neither "disappointed" nor "disoriented" - just confused over what exactly the OP wants this code to do. :graduated:

Congratulations to France - it looks as if Laurent Blanc has got the basis for a good team there. I would have enjoyed watching them play even more if it had been at someone else's expense. :(

M23

@Melba23

oh! "Donkey" you're severe!

remember they were playing against the great team of France !

and sorry for the English bookmakers ...

I hope you do not lose money... Posted Image

wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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