Jump to content

Recommended Posts

Posted (edited)

Just browsing through the helpfile trying to solve a problem and i wasnt sure about this

For eg

I have a number of different files to check for in a folder but they have different executions depending on whats available, and there maybe more than one type available.

So i need it to keep going until they are all done

eg of one below

        $aRarFile = _RecFileListToArray(@ScriptDir, "*.7z", 1, 0)
;~         _ArrayDisplay($aRarFile, ".Rar Files")
        If IsArray($aRarFile) Then
            $test = RunWait(@ComSpec & ' /c ' & @TempDir & '\7z.exe' & ' x -y ' & '"' & $FileEnd & '"', "", @SW_HIDE)
            Sleep(200)
        EndIf

So i was debating using

Select
        Case $aRarFile = _RecFileListToArray(@ScriptDir, "*.7z", 1, 0)
;~         _ArrayDisplay($aRarFile, ".Rar Files")
            If IsArray($aRarFile) Then
                $test = RunWait(@ComSpec & ' /c ' & @TempDir & '\7z.exe' & ' x -y ' & '"' & $FileEnd & '"', "", @SW_HIDE)
            EndIf
        ContinueCase
        Case $aRarFile = _RecFileListToArray(@ScriptDir, "*.rar", 1, 0) ; etc etc
Endselect

But the bit im not sure about is

Does ContinueCase override Select's natural only first one is executed setting?

Edited by Chimaera
  • Moderators
Posted

Chimaera,

No,  only the first True case will fire.  All ContinueCase does is to run the code in the next Case down regardless of the condition:

$iTest = 10

Switch $iTest
    Case 10
        ConsoleWrite("$iTest = 10" & @CRLF)
    Case 11
        ConsoleWrite("$iTest = 11" & @CRLF)
    Case 12
        ConsoleWrite("$iTest = 12" & @CRLF)
EndSwitch

ConsoleWrite(@CRLF)

$iTest = 20

Switch $iTest
    Case 20
        ConsoleWrite("$iTest = 20" & @CRLF)
        ContinueCase
    Case 21
        ConsoleWrite("$iTest = 21" & @CRLF)
        ContinueCase
    Case 22
        ConsoleWrite("$iTest = 22" & @CRLF)
EndSwitch

Clearer now? :)

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

 

Posted (edited)

Ok so that will not achieve what im after.

What about Do - Until can i make that do a number of times through?

Cant say ive ever used it

EDIT unfortunatly they dont have compatible search params so i cant lump them all together

Edit 2

Solved now by making 4 different functions and run them from a master function

Edited by Chimaera
Posted

What I would be inclined to do would be to count tasks upon completion. Put all the conditions in a loop (eg: Do ... Until $iCount = 10). caution is required that you don't count the same task twice.

Posted

My code example can be improved, but it is only intended as an example of a Select statement within a Do Until loop.

Local $iTest1 = True, $iTest2 = True, $iTest3 = True, $iTest4 = True, $iTest5 = True, $iTest6 = True, $iCount = 0

Do
    Select
        Case $iTest1 And @SEC >= 0 And @SEC < 10
            ConsoleWrite(@SEC & @LF)
            $iTest1 = False
            $iCount += 1

        Case $iTest2 And @SEC >= 10 And @SEC < 20
            ConsoleWrite(@SEC & @LF)
            $iTest2 = False
            $iCount += 1

        Case $iTest3 And @SEC >= 20 And @SEC < 30
            ConsoleWrite(@SEC & @LF)
            $iTest3 = False
            $iCount += 1

        Case $iTest4 And @SEC >= 30 And @SEC < 40
            ConsoleWrite(@SEC & @LF)
            $iTest4 = False
            $iCount += 1

        Case $iTest5 And @SEC >= 40 And @SEC < 50
            ConsoleWrite(@SEC & @LF)
            $iTest5 = False
            $iCount += 1

        Case $iTest6 And @SEC >= 50 And @SEC < 60
            ConsoleWrite(@SEC & @LF)
            $iTest6 = False
            $iCount += 1
    EndSelect
Until $iCount = 6
Posted (edited)

So the icount forces it to run each section until the required condition is met

I resolved my original problem by creating a master function (my terminology)

Func _UnRar() ; Unpack all files
    Local $CleanUpData = _RecFileListToArray(@ScriptDir, "*|*acker.exe;*.au3", 1, 0)
;~  _ArrayDisplay($CleanUpData, "CleanUp Files")
    If IsArray($CleanUpData) Then
        _Archive_1()
        _Archive_2()
        _Archive_3()
        _Archive_4()
    Else
        MsgBox(64, "Error " & @error, "    No Rar Files Available For Extraction", 2)
    EndIf
    $CleanUpFiles = $CleanUpData
    Return $CleanUpFiles
EndFunc   ;==>_UnRar

Func _Archive_1()
        $aRarFile = _RecFileListToArray(@ScriptDir, "*.rar|*.part*", 1, 0)
;~      _ArrayDisplay($aRarFile, ".Rar Files")
        If IsArray($aRarFile) Then
            For $i = 1 To $aRarFile[0]
            $test = RunWait(@ComSpec & ' /c ' & @TempDir & '\7z.exe' & ' x -y ' & '"' & $aRarFile[$i] & '"', "", @SW_HIDE)
            Next
        EndIf
            Sleep(200)
EndFunc  ;>> _Archive_1()

and then make each array work properly on its own and call them one after another.

Thanks for the explanation though

Edited by Chimaera
Posted

I tend to be very one dimensional i guess with Autoit

I get something that works and stick with it where possible, probably because i don't code for a living and my stuff rarely branches out, like my solution above it reuses what i know to get the job done.

Im doing something different atm which requires me to revisit stuff so its all good really

Posted (edited)

I tend to be very one dimensional i guess with Autoit

 

I'm the same although I hate to admit it. I can pretty much most things with strings arrays numbers and loops. There are lots of alternatives I could use, but the time to learn new things has to be weighed against other time constraints. I often wait until I have a working model before I think of ways to improve things. Then if I do adopt a different approach, I can see (and appreciate) the differences.

Edited by czardas

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...