Jump to content

Need Help With Script For Copy Process


Guest bandit
 Share

Recommended Posts

Guest bandit

Hi All,

I am a newbie trying to figure how to do this simple script using autoit3, think u get the idea looking at the script below but not sure how to get it to work. Help please? :ph34r:

$answer = MsgBox(4, "MOVE FTP FILES TO THE CORRECT DIR", "Want To Copy Perform It Now?")
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(4096, "Cancelled", "OK.  Bye!")
    Exit
EndIf

$text = InputBox("SAT/SUN/PDAY", "Please type in Your Choice and click OK")
If $text = "SAT" Then  
    SatFunc()  
EndIf  

Func SatFunc()
    FileMove("C:\FTP\*.dly", "C:\daily\Sat\")
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
        ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Julian's Messagge","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()
Endfunc

EXIT
if $text = "SUN" Then
    SunFunc()
EndIf

Func SunFunc()
    FileMove("C:\FTP\*.dly", "C:\daily\Sun\")
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
     ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Julian's Messagge","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()
Endfunc

EXIT
if $text = "PDAY" Then
    PdayFunc()
EndIf

Func PdayFunc()
    FileMove("C:\FTP\*.dly", "C:\daily\Pday\")
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
        ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Sys Message","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()     
EndFunc

Exit

edit: fixed indentation

Edited by Larry
Link to comment
Share on other sites

Wouldn't it be easier just to combine these three different functions doing essentially the same thing with a little variation and only use one func:

$answer = MsgBox(4, "MOVE FTP FILES TO THE CORRECT DIR", "Want To Copy Perform It Now?")
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(4096, "Cancelled", "OK.  Bye!")
    Exit
EndIf

$text = InputBox("SAT/SUN/PDAY", "Please type in Your Choice and click OK")
_CopyFunc($text)
Exit

Func _CopyFunc($option)
    If $option <> "sat" AND $option <> "sun" AND $option <> "pday" Then
             MsgBox(4096, "Error", "Unrecognized option")
             Exit
   EndIf
   FileMove("C:\FTP\*.dly", "C:\daily\" & $option)
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
        ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Sys Message (" & $option & ")","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()  
EndFunc
Link to comment
Share on other sites

Guest bandit

Thank you so much for your guidance....

After fixing your indentation I could read that your logic after the inputbox is mussed. Functions are seperate entities in a script and those "Func"s can be called in your script. So some of your code straggled at the end and you had exits that kept the process from ever reaching some of your logic... see my changes...

$answer = MsgBox(4, "MOVE FTP FILES TO THE CORRECT DIR", "Want To Copy Perform It Now?")
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(4096, "Cancelled", "OK.  Bye!")
    Exit
EndIf

$text = InputBox("SAT/SUN/PDAY", "Please type in Your Choice and click OK")
If $text = "SAT" Then  
    SatFunc()  
EndIf  
if $text = "PDAY" Then
    PdayFunc()
EndIf
if $text = "SUN" Then
    SunFunc()
EndIf
Exit

;ALSO HERE YOU CAN USE Select Case
;replace the Ifs above with this Select/Case logic...

;Select
;    Case $text = "SAT"
;        SatFunc()  
;    Case $text = "PDAY"
;        PdayFunc()
;    Case $text = "SUN"
;        SunFunc()
;EndSelect
;Exit

Func SatFunc()
    FileMove("C:\FTP\*.dly", "C:\daily\Sat\")
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
        ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Julian's Messagge","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()
Endfunc

Func SunFunc()
    FileMove("C:\FTP\*.dly", "C:\daily\Sun\")
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
        ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Julian's Messagge","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()
Endfunc

Func PdayFunc()
    FileMove("C:\FTP\*.dly", "C:\daily\Pday\")
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
        ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Sys Message","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()     
EndFunc

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Guest bandit

Isn't that the beauty of writing scripts, if & when u have the knowledge you can have different variations to solve the problem. Thanks so much for your time and help.

Wouldn't it be easier just to combine these three different functions doing essentially the same thing with a little variation and only use one func:

$answer = MsgBox(4, "MOVE FTP FILES TO THE CORRECT DIR", "Want To Copy Perform It Now?")
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(4096, "Cancelled", "OK.  Bye!")
    Exit
EndIf

$text = InputBox("SAT/SUN/PDAY", "Please type in Your Choice and click OK")
_CopyFunc($text)
Exit

Func _CopyFunc($option)
    If $option <> "sat" AND $option <> "sun" AND $option <> "pday" Then
             MsgBox(4096, "Error", "Unrecognized option")
             Exit
   EndIf
   FileMove("C:\FTP\*.dly", "C:\daily\" & $option)
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
    For $i = 10 to 100 step 10
        sleep(1000)
        ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Done", "Complete")
    sleep(500)
    ProgressOff()
    SplashTextOn("Sys Message (" & $option & ")","Mission Accomplished...End", 400,200,-1,-1,-4, "", 24)
    Sleep(5000)
    SplashOff()     
EndFunc

<{POST_SNAPBACK}>

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