Sign in to follow this  
Followers 0
James

Case structure - For Next loop

7 posts in this topic

#1 ·  Posted (edited)

Hi all,

I have been working on external skin packages for Disk Manager. I have managed to create the menu items for any *.DMS files found in the @ScriptDir & '\Themes' directory:

; Find all *.DMS - Skin files
 GLobal $Skins = _FileListToArray(@ScriptDir & '\Themes'), $SkinFile[30]
 
 $M_Colours = GUICtrlCreateMenu("Colour Scheme", $M_Options)
 For $s = 1 To $Skins[0]
     $SkinFile[$s] = GUICtrlCreateMenuItem($Skins[$s], $M_Colours)
 Next

Now what I need to know is how to write the Case structure for menu items. I could have 10 skin files or 30. I have tried writing a For Next loop around the Case $SkinFiles[$a] like so, but complains I am missing Select, EndSelect etc.

I currently have:

Case $iMsg = $SkinFile[1]
     MsgBox(0, "Disk Manager", "Selected " & $Skins[1] & " as the chosen theme!")
     $Scheme = IniReadSection($Skins, "Scheme")
     For $ia = 1 To $Scheme[0][0]
         MsgBox(4096, "", "Key: " & $Scheme[$ia][0] & @CRLF & "Value: " & $Scheme[$ia][1])
     Next
     For $z = 1 To $_AllD[0]
         GUICtrlSetBkColor($Progress[$z], $Scheme[1][1]); Back
         GUICtrlSetColor($Progress[$z], $Scheme[2][1]); Front
         GUICtrlSetColor($ConsoleBox, $Scheme[3][1]); Console
     Next

But this wont work because it cannot find the skin file to read through the settings.

My *.DMS file is an INI file but with a custom extension :)

Thanks,

James

Edited by Jiim

Share this post


Link to post
Share on other sites



Hi all,

I have been working on external skin packages for Disk Manager. I have managed to create the menu items for any *.DMS files found in the @ScriptDir & '\Themes' directory:

; Find all *.DMS - Skin files
 GLobal $Skins = _FileListToArray(@ScriptDir & '\Themes'), $SkinFile[30]
 
 $M_Colours = GUICtrlCreateMenu("Colour Scheme", $M_Options)
 For $s = 1 To $Skins[0]
     $SkinFile[$s] = GUICtrlCreateMenuItem($Skins[$s], $M_Colours)
 Next

Now what I need to know is how to write the Case structure for menu items. I could have 10 skin files or 30. I have tried writing a For Next loop around the Case $SkinFiles[$a] like so, but complains I am missing Select, EndSelect etc.

I currently have:

Case $iMsg = $SkinFile[1]
     MsgBox(0, "Disk Manager", "Selected " & $Skins[1] & " as the chosen theme!")
     $Scheme = IniReadSection($Skins, "Scheme")
     For $ia = 1 To $Scheme[0][0]
         MsgBox(4096, "", "Key: " & $Scheme[$ia][0] & @CRLF & "Value: " & $Scheme[$ia][1])
     Next
     For $z = 1 To $_AllD[0]
         GUICtrlSetBkColor($Progress[$z], $Scheme[1][1]); Back
         GUICtrlSetColor($Progress[$z], $Scheme[2][1]); Front
         GUICtrlSetColor($ConsoleBox, $Scheme[3][1]); Console
     Next

But this wont work because it cannot find the skin file to read through the settings.

My *.DMS file is an INI file but with a custom extension :)

Thanks,

James

Are all the different skins in different file DMS files? If so how are the names arranged?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Different names. Horizon, Simple, whatever the author makes it.

I see. Then I suppose you need something like this.(Modified so I could test.)

#include <file.au3>
; Find all *.DMS - Skin files
Global $Skins = _FileListToArray(@ScriptDir & '\Themes'), $SkinFile[30]
$g = GUICreate("")
$M_Colours = GUICtrlCreateMenu("Colour Scheme",-1); $M_Options)
GUISetState()
For $s = 1 To $Skins[0]
    $SkinFile[$s] = GUICtrlCreateMenuItem($Skins[$s], $M_Colours)
Next

While 1
    $iMsg = GUIGetMsg()
    
    Switch $iMsg
        Case -3
            Exit
        Case $SkinFile[1] To $SkinFile[$Skins[0]]
            $SkinCilcked = ''
            For $s = 1 To $Skins[0]
                If $iMsg = $SkinFile[$s] Then
                    $SkinCilcked = $Skins[$s]
                    ExitLoop
                EndIf
            Next
            If $SkinCilcked <> '' Then
                MsgBox(0, "Disk Manager", "Selected " & $SkinCilcked & " as the chosen theme!")
                $Scheme = IniReadSection("Themes\" & $SkinCilcked, "Scheme")
                For $ia = 1 To $Scheme[0][0]
                    MsgBox(4096, "", "Key: " & $Scheme[$ia][0] & @CRLF & "Value: " & $Scheme[$ia][1])
                Next
                #cs
                For $z = 1 To $_AllD[0]
                    GUICtrlSetBkColor($Progress[$z], $Scheme[1][1]); Back
                    GUICtrlSetColor($Progress[$z], $Scheme[2][1]); Front
                    GUICtrlSetColor($ConsoleBox, $Scheme[3][1]); Console
                Next
                #ce
            EndIf
            
    EndSwitch
    
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I never knew about using To on a Case statement :) - Scrap that it didn't work.

C:\Documents and Settings\James\My Documents\Programming\AutoIt\Disk Manager\DMan4AutoIt3-ExSkins.au3(222,21) : ERROR: syntax error
        Case $SkinFile[1] To
        ~~~~~~~~~~~~~~~~~~^
Edited by Jiim

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I never knew about using To on a Case statement :) - Scrap that it didn't work.

C:\Documents and Settings\James\My Documents\Programming\AutoIt\Disk Manager\DMan4AutoIt3-ExSkins.au3(222,21) : ERROR: syntax error
        Case $SkinFile[1] To
        ~~~~~~~~~~~~~~~~~~^
I guess you tried to do it with Select-Case-EndSelect instead of Switch-Case-EndSwitch. I did point out that I had tested what I showed and I changed to Switch-Case-EndSwitch on purpose.

EDIT:

If you want to use Select you need to have

Case $iMsg >= $SkinFile[1] And $iMsg <= $SkinFile[$Skins[0]]
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I guess you tried to do it with Select-Case-EndSelect instead of Switch-Case-EndSwitch. I did point out that I had tested what I showed and I changed to Switch-Case-EndSwitch on purpose.

EDIT:

If you want to use Select you need to have

Case $iMsg >= $SkinFile[1] And $iMsg <= $SkinFile[$Skins[0]]
So you did. Thanks Martin! Great help :)

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