Jump to content
Sign in to follow this  
dmorand

Need help with case statement

Recommended Posts

dmorand

Ok I'm trying to port my vbscript to au3 because I like this scripting language for all of the added functionality, and I can make forms, blah blah blah.

I know I'm just being a moron, but I'm hoping someone can help me out.

I'm getting an error when I try to run (see bolded function).

"EndSwitch" statement with no matching "Switch" statement." is the error I'm getting

What am I doing wrong? I'm basically just trying to get some cases setup for the various options that $application can be.

#include <GUIConstants.au3>
;--------------------------------------------------------------------------------------------
;  Release Version: 1.0
;  Description:  This script will copy the necessary ini files for the following apps:
;                       Admin Desktop
;                       Pharmacy
;               The following ini files will be copied to the c:\windows directory
;               when an application is selected:
;                       MXS_Pharmacy.ini
;                       MXS_AdminDesktop.ini
;               Now with an application launcher Menu!!
;
;  Author: Doug Morand 
;  Date: 09-14-2007
;--------------------------------------------------------------------------------------------

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\DMORAND\Desktop\Koda\Forms\App_Launcher.kxf
$Form1 = GUICreate("Form1", 348, 353, 315, 115)
$app_lst = GUICtrlCreateList("", 144, 48, 185, 253)
GUICtrlSetData(-1, "Admin Desktop - Production|Admin Desktop - Test|EDM - Prod|EDM - Test|Mak|Novius Lab|Novius Rad|Pharmacy|Soarian Clinicals - Prod|Soarian Clinicals - Test|Soarian Financials - Prod|Soarian Financials - Test")
$launch_btn = GUICtrlCreateButton("Launch Application", 144, 304, 105, 41)
$quit_btn = GUICtrlCreateButton("Quit", 256, 304, 73, 41)
$Label1 = GUICtrlCreateLabel("Application Launcher v1.0", 8, 8, 306, 32)
GUICtrlSetFont(-1, 18, 400, 0, "Arial Rounded MT Bold")
$Group1 = GUICtrlCreateGroup("Instructions", 8, 64, 129, 217)
$Label2 = GUICtrlCreateLabel("Welcome to the aplication lancher", 10, 79, 125, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $launch_btn
            _launchapp()
        Case $quit_btn
            _quitlauncher()
        Exit
    EndSwitch
WEnd

Set $fso = CreateObject("Scripting.FileSystemObject")
Set $WshShell = CreateObject("WScript.Shell")
Set $objNet = CreateObject("WScript.Network") 

;******************************** Application Executables

$pharmacy = "C:\Progra~1\SMS\PCW\I86\23079034\bin\PCWSTAPL.EXE"
$mak = "C:\Progra~1\SMS\MAK\I86\23049033\bin\MAKSTAPL.EXE"
$adminDeskP = "C:\Progra~1\Siemens\Soarian20530207\HAP1\Production\bin\DesktopApplication.exe"
$adminDeskT = "C:\Progra~1\Siemens\Soarian20530192\HAT1\Test\bin\DesktopApplication.exe"

;******************************** Web site Links ********************************

;EVTS Tickets
$evts = "https://www11.smed.com/"

;Clinicals Prod
$clinP = "http://soarianweb/020530207_HAP1_p/dsk/SuidkLogon.jsp"

;Clinicals Test
$clintT = "http://srnclintst/020530192_HAT1_t/dsk/SuidkLogon.jsp"

;Financials Production
$finP = "http://srf505001.rsodm20.smsrsm.com/5050-SF-PROD/soarian/logon.pba"

;Financials Test 
$finT = "http://srf505001.rsodm20.smsrsm.com/5050-SF-TEST/soarian/logon.pba"

[b]
func _launchapp()
    $application = GUICtrlRead($app_lst)
    Switch $application
        case $application = "Admin Desktop - Production"
            if FileExists($adminDeskP) then
                FileCopy("\\ISOPS\Analysts\INI_Repository\MXS_AdminDesktop.ini","C:\Windows\MXS.ini",TRUE)
                fncRun($adminDeskP)
            else
                MsgBox(16,"Invalid Application","You dont have Admin Desktop Production installed!")
            end if
            MsgBox(0,"title","You selected: " & $application)
        Exit
    EndSwitch
endfunc
[/b]

func _quitlauncher()
    Exit    
EndFunc

;******************************************** Run Executable Function ********************************************************

func fncRun ($app)
    
    $appReturn = Run($app)
    
EndFunc

;******************************************** Launch IE Function ********************************************************

Func fncExplorer ($link)
  
    $linkReturn = Run("iexplore " & $link)

EndFunc

Share this post


Link to post
Share on other sites
SmOke_N

Switch is probably like your Select Case.

Instead of:

Switch $application
        case $application = "Admin Desktop - Production"oÝ÷ Ù:òjëh×6    Switch $application
        case "Admin Desktop - Production"

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
dmorand

Switch is probably like your Select Case.

Instead of:

Switch $application
        case $application = "Admin Desktop - Production"oÝ÷ Ù:òjëh×6    Switch $application
        case "Admin Desktop - Production"
Cool let me try that!!

Share this post


Link to post
Share on other sites
weaponx

I second SmOke_N on this one.

Share this post


Link to post
Share on other sites
weaponx

You are wrong. Switch syntax is simpler if you are always comparing against the same input variable.

Edited by weaponx

Share this post


Link to post
Share on other sites
weaponx

There is only one now but the list he using (GUICtrlRead($app_lst)) will probably have multiple values.

Share this post


Link to post
Share on other sites
dmorand

There is only one now but the list he using (GUICtrlRead($app_lst)) will probably have multiple values.

Yes my list will have a lot of values, at least 20 I'm thinking. I was just making sure 1 worked before I kept going.

Btw, I got it working using the Switch method mentioned by Smoke_N Thanks a bunch!!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.