Jump to content

how do i run an if = 0 with func


yasha
 Share

Recommended Posts

so i have a while loop program with a func to select the folder where the file will be saved now i want to add an if =0 then instructions to run the program pop up in message box without have the select folder func run.

Func Example()
$sFolder = ""
    ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
    Local Const $sMessage = "Select a folder"

    ; Display an open dialog to select a file.
    $sFileSelectFolder = FileSelectFolder($sMessage, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
        Exit
    Else
        ; Display the selected folder.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)

    EndIf
$charcnt = 1
while $charcnt < 40

if $selectedflag[$charcnt] = 0 Then
  $input1 = MsgBox(1, "Instructions", "1) Enter the report number in the box with a space in between" & @LF & " text on second line")
  Exit
  if $input1 = 2 Then
    Exit
 EndIf
   EndIf
sleep(10)
;1)SO
if $selectedflag[$charcnt] = 1 Or $selectedflag[$charcnt] = 21 Then
EndIf
sleep(10)

 

Link to comment
Share on other sites

This is very confusing to me.

you already have an if =0, this one

if $selectedflag[$charcnt] = 0 Then

The function "example" is never called in your posted script, i dont know what $selectedflag is, the while loop is never closed.

Honestly i have no idea what the problem is and why you couldn't solve it.

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

my whole program is very long almost 2500 lines 

ok so i have a input box when i run the program i type in numbers 1 to 20 to run different programs 

once i type in any number the func will open a window to ask me where i want to save the results and then it will run the while loop depending on what number i typed in the message box .

now i want to type 0 in the inputbox and only come up with a msgbox to show something and then close.

this part is when i have problem cause i dont want the func to run .

i tried moving the function below if = 0 but it kept running 0 even when i type other number 

it works when the func is on top but the func run which i dont want i tried having 2 seperate while and wend but it does not run .

 

Link to comment
Share on other sites

@yasha, It would be great if you can provide more detailed information of what you want us to do and provide a running code. Also, can you check your while loop why exit after input box?

 

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

5 minutes ago, yasha said:

once i type in any number the func will open a window to ask me where i want to save the results and then it will run the while loop depending on what number i typed in the message box .

You want to save the results but you posted FileSelectFolder() in your func. Maybe you want FileSaveDialog() in saving file/s.

 

8 minutes ago, yasha said:

now i want to type 0 in the inputbox and only come up with a msgbox to show something and then close.

Okay this make sense;). Now, what is the $selectedflag in your code? is this the number inputted?

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

#include <ClipBoard.au3>
#include <ClipBoard.au3>
#include <array.au3>
#include <Date.au3>
#include <Excel.au3>
#include <ExcelConstants.au3>
#include <MsgBoxConstants.au3>
$variable1 = TimerInit
AutoItSetOption ( "WinTitleMatchMode",2)
AutoItSetOption ( 'MouseCoordMode',0)

$reportname = StringSplit("                                                                                                    ","")
$reportname[0] = "0 For instructions press 0 "
$reportname[1] = "1 SO "
$reportname[2] = "2 PRrod"
$reportname[3] = "3 PRP Pur"
$reportname[4] = "4 P Claim"
$reportname[5] = "5 u Claim"
$reportname[6] = "6 whs "
$reportname[7] = "7 PRP"
$reportname[8] = "8 Proj"
$reportname[9] = "9 Tlist  "
$reportname[10]= "10 claim"
$reportname[11]= "11 IN Plan "
$reportname[12]= "12 IN "
$reportname[13]= "13 IT "
$reportname[14]= "14 Material "
$reportname[15]= "15 IQA"
$reportname[16]= "16 ILC "
$reportname[17]= "17 Econom"
$reportname[18]= "18 Prol"
$reportname[19]= "19 Pro C"
$reportname[20]= "20 Pe"
$reportname[21]= "21 RUN 1 to 20 (All Range)"
$reportname[22]= "22 Rae"
$reportname[23]= "23 Rck"
$reportname[24]= "24 Compile "
$reportname[25]= "25 RUN 22 to 24 (Selectable Range)"
$charcnt = 0
$reportname_show = ""
while $reportname[$charcnt] <> " "
    $reportname_show = $reportname_show & @CR & $reportname[$charcnt]
    $charcnt = $charcnt + 1
 WEnd

$selection = InputBox("Baan Reports Selection",$reportname_show & @CR & @CR &"Please Enter selection as Numbers, with 1 space in-between" & @CR,""," M",350,550,650,450)
If @error Then Exit

$charcnt = 1
$selected = ""
$selectedflag = StringSplit("                                                                                                    ","")
$reportname[0] = ""


while $charcnt < 40
    if int(Stringmid($selection, $charcnt,1)) >= 0 then
        if int(Stringmid($selection, $charcnt,2)) < 10 then
            $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,1))]
            $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,1))
            $charcnt = $charcnt + 2
        Else
            $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,2))]
            $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,2))
            $charcnt = $charcnt + 3
        EndIf
    EndIf
 WEnd

$sFolder = ""
    ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
    Local Const $sMessage = "Select a folder"

    ; Display an open dialog to select a file.
    $sFileSelectFolder = FileSelectFolder($sMessage, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
        Exit
    Else
        ; Display the selected folder.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)

    EndIf

$input = MsgBox(1, "", "Reports Selected -> START ALL RANGE:" & @CR & $selected & @CR & @CR &"Click Ok to proceed, Cancel to End")

if $input = 2 Then
    Exit
 EndIf




$baantmpdir = "C:\Users\" & @UserName & "\AppData\Local\Infor\BW\Baan IV\"
$baandir = "C:\Program Files (x86)\Infor\BW\Baan IV\"

$Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
$YY=StringFormat("%02i",@YEAR-2000)
$MM=StringFormat("%02i",Int(@MON))
$DD=StringFormat("%02i",Int(@MDAY))


$Baan_exist = 0
If WinExists("Menu browser [User: ") then
$Baan_exist = 1
EndIf





$charcnt = 1

while $charcnt < 40
;if $selectedflag[$charcnt] = 0 Then
 ; $input1 = MsgBox(1, "Instructions", "1) Enter the report number in the box with a space in between" & @LF & "2) text on second line")
 ; Exit
  ;if $input1 = 2 Then
;   Exit
 ;EndIf
  ;EndIf
sleep(10)

;1)SO
if $selectedflag[$charcnt] = 1 Or $selectedflag[$charcnt] = 21 Then


EndIf
sleep(10)
;2)PRP 
if $selectedflag[$charcnt] = 2 Or $selectedflag[$charcnt] = 21 Then


EndIf
Sleep(10)
;3)PRP P
if $selectedflag[$charcnt] = 3 Or $selectedflag[$charcnt] = 21 Then

     EndIf
sleep(10)
;4)Prod 
if $selectedflag[$charcnt] = 4 Or $selectedflag[$charcnt] = 21 Then


EndIf
Sleep(10)
;5)purcha
if $selectedflag[$charcnt] = 5 Or $selectedflag[$charcnt] = 21 Then

EndIf
Sleep(10)

;there is more .

$charcnt = $charcnt + 1
WEnd


if $Baan_exist = 0 then
   WinClose("Menu browser [User: ")
EndIf

important parts of my program the insides u need to fill it with your own instructions sorry

i need a way to only get the func work with every thing except 0

Edited by yasha
Link to comment
Share on other sites

@yasha, note sure if this is what you want, but as what you stated, you don't want to FileSelectFolder() if = 0 then message box to check right?

 

#include <ClipBoard.au3>
#include <ClipBoard.au3>
#include <array.au3>
#include <Date.au3>
#include <Excel.au3>
#include <ExcelConstants.au3>
#include <MsgBoxConstants.au3>
$variable1 = TimerInit
AutoItSetOption ( "WinTitleMatchMode",2)
AutoItSetOption ( 'MouseCoordMode',0)

$reportname = StringSplit("                                                                                                    ","")
$reportname[0] = "0 For instructions press 0 "
$reportname[1] = "1 SO "
$reportname[2] = "2 PRrod"
$reportname[3] = "3 PRP Pur"
$reportname[4] = "4 P Claim"
$reportname[5] = "5 u Claim"
$reportname[6] = "6 whs "
$reportname[7] = "7 PRP"
$reportname[8] = "8 Proj"
$reportname[9] = "9 Tlist  "
$reportname[10]= "10 claim"
$reportname[11]= "11 IN Plan "
$reportname[12]= "12 IN "
$reportname[13]= "13 IT "
$reportname[14]= "14 Material "
$reportname[15]= "15 IQA"
$reportname[16]= "16 ILC "
$reportname[17]= "17 Econom"
$reportname[18]= "18 Prol"
$reportname[19]= "19 Pro C"
$reportname[20]= "20 Pe"
$reportname[21]= "21 RUN 1 to 20 (All Range)"
$reportname[22]= "22 Rae"
$reportname[23]= "23 Rck"
$reportname[24]= "24 Compile "
$reportname[25]= "25 RUN 22 to 24 (Selectable Range)"
$charcnt = 0
$reportname_show = ""
while $reportname[$charcnt] <> " "
    $reportname_show = $reportname_show & @CR & $reportname[$charcnt]
    $charcnt = $charcnt + 1
 WEnd

$selection = InputBox("Baan Reports Selection",$reportname_show & @CR & @CR &"Please Enter selection as Numbers, with 1 space in-between" & @CR,""," M",350,550,650,450)
If @error Then Exit
if $selection = 0 Then
$input1 = MsgBox(1, "Instructions", "1) Enter the report number in the box with a space in between" & @LF & "2) text on second line")
Exit
EndIf
$charcnt = 1
$selected = ""
$selectedflag = StringSplit("                                                                                                    ","")
$reportname[0] = ""


while $charcnt < 40
    if int(Stringmid($selection, $charcnt,1)) >= 0 then
        if int(Stringmid($selection, $charcnt,2)) < 10 then
            $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,1))]
            $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,1))
            $charcnt = $charcnt + 2
        Else
            $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,2))]
            $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,2))
            $charcnt = $charcnt + 3
        EndIf
    EndIf
 WEnd

$sFolder = ""
    ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
    Local Const $sMessage = "Select a folder"

    ; Display an open dialog to select a file.
    $sFileSelectFolder = FileSelectFolder($sMessage, "")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
        Exit
    Else
        ; Display the selected folder.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)

    EndIf

$input = MsgBox(1, "", "Reports Selected -> START ALL RANGE:" & @CR & $selected & @CR & @CR &"Click Ok to proceed, Cancel to End")

if $input = 2 Then
    Exit
 EndIf




$baantmpdir = @ScriptDir & @UserName & "\"
$baandir = @ScriptDir & @UserName & "\BW\"

$Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
$YY=StringFormat("%02i",@YEAR-2000)
$MM=StringFormat("%02i",Int(@MON))
$DD=StringFormat("%02i",Int(@MDAY))


$Baan_exist = 0
If WinExists("Menu browser [User: ") then
$Baan_exist = 1
EndIf

$charcnt = 1

while $charcnt < 40
;~ sleep(10)

;1)SO
if $selectedflag[$charcnt] = 1 Or $selectedflag[$charcnt] = 21 Then
MsgBox(0,"","Selected 1 or 21")
Exit
EndIf
sleep(10)
;2)PRP
if $selectedflag[$charcnt] = 2 Or $selectedflag[$charcnt] = 21 Then
MsgBox(0,"","Selected 2 or 21")
Exit
EndIf
Sleep(10)
;3)PRP P
if $selectedflag[$charcnt] = 3 Or $selectedflag[$charcnt] = 21 Then
MsgBox(0,"","Selected 3 or 21")
Exit
     EndIf
sleep(10)
;4)Prod
if $selectedflag[$charcnt] = 4 Or $selectedflag[$charcnt] = 21 Then
MsgBox(0,"","Selected 4 or 21")
Exit

EndIf
Sleep(10)
;5)purcha
if $selectedflag[$charcnt] = 5 Or $selectedflag[$charcnt] = 21 Then
MsgBox(0,"","Selected 5 or 21")
Exit
EndIf
Sleep(10)

;there is more .

$charcnt = $charcnt + 1
WEnd


if $Baan_exist = 0 then
   WinClose("Menu browser [User: ")
EndIf

Updated.

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

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