Sign in to follow this  
Followers 0
Freshprince

Need help at a if else loop

8 posts in this topic

Hey everyone!

Iam working on a project

it should do the following:

- Clear a directory && download some content (works)

- After this, it should open a programm and the following ones,have to wait (works)

- A search has to be done,for a specific directory,if there are no datas,there comes a massage box with" no datas in

here" , or when datas there,a batch runs .

my code is this

#include <string.au3>

#include <array.au3>

#include <file.au3>

$SearchDir="M:\AUTO_JOB\ALK_Daten\Tab"

$SearchFiles= "*.DAT"

$SearchFiles= "*.MAP"

$SearchFiles= "*.IND"

$SearchFiles= "*.ID"

DirRemove("M:\AUTO_JOB\Tab")

InetGet("ftp:andsoon...", "AL001_001_0000_00_GF_TB.prj",1)

Sleep(1000)

DirCreate("M:\AUTO_JOB\Tab")

ShellExecuteWait("M:\AUTO_JOB\Programm")

$FolderList=_FileListToArray($SearchDir & "M:\AUTO_JOB\Tab", $Searchfiles,1)

If (Not IsArray($FolderList)) then

MsgBox(0,"No Data in here",1)

ELSE

Run("M:\AUTO_JOB\Batch.bat")

EndIf

EndIf

I would be very very happy if someone could help me with that,im tryin for hours /and nothing goes:(

and one question to it :i know with Inetget you can download ,i can do it with one data..Does it works with a

directory??

Thank you,to everyone who helps me:)

Share this post


Link to post
Share on other sites



Freshprince,

You cannot look for more than one file type at a time with _FileListToArray, so you need to loop through the 4 options like this:

#include <string.au3>
#include <array.au3>
#include <file.au3>

$SearchDir="M:\AUTO_JOB\ALK_Daten\Tab"
; create an array to hold the file types (you can only use one at a time)
Global $SearchFiles[4]
$SearchFiles[0]= "*.DAT"
$SearchFiles[1]= "*.MAP"
$SearchFiles[2]= "*.IND"
$SearchFiles[3]= "*.ID"

DirRemove("M:\AUTO_JOB\Tab")
InetGet("ftp:andsoon...", "AL001_001_0000_00_GF_TB.prj",1)
Sleep(1000)

DirCreate("M:\AUTO_JOB\Tab")
ShellExecuteWait("M:\AUTO_JOB\Programm")

; Now look for the file types we listed earlier
; Set a flag to see if files were present
$fFlag = False
For $i = 0 To 3
    ; Move through the array looking for each type in turn
    $FolderList=_FileListToArray($SearchDir & "M:\AUTO_JOB\Tab", $Searchfiles[$i],1)
    ; If we find some files than set the flag)
    If IsArray($FolderList) Then $fFlag = True
Next

; If we found files then run your batch file
If $fFlag = True Then
    Run("M:\AUTO_JOB\Batch.bat")
; If not
Else
    MsgBox(0,"No Data in here",1)
EndIf

I hope this helps. Please ask if anything is unclear. :D

M23

P.S. When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Hey!

First i wanna thanks for the Script you postet!:D

And i`ve got questions:)

So,i tried it,but it comes always the Messagebox with" No data in here" ,even when i have datas in the tab directory

i just made a data with the search function and if datas the batch should run...

in the line " $FolderList=_FileListToArray($SearchDir & "M:\AUTO_JOB\ALK_Daten\Tab", $Searchfiles[$i],1)" i made

$SearchFiles so a big F..But that wasnt the point.. so what could be the problem?

Share this post


Link to post
Share on other sites

Hey!

First i wanna thanks for the Script you postet!:D

And i`ve got questions:)

So,i tried it,but it comes always the Messagebox with" No data in here" ,even when i have datas in the tab directory

i just made a data with the search function and if datas the batch should run...

in the line " $FolderList=_FileListToArray($SearchDir & "M:\AUTO_JOB\ALK_Daten\Tab", $Searchfiles[$i],1)" i made

$SearchFiles so a big F..But that wasnt the point.. so what could be the problem?

Psst, post some code, I happen to know that Melba23 is having trouble charging the batteries for his crystal ball.

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

That was my original script

it should

1.remove a directory ,load a project data create a directory and open a programm which works and after that the

other programs begin..so far it worked all..

2. BUT the next step is,a directory should been searched after the 4 diffrent datatypes,and then,if there are

datas in the directory a batch should been startet,or when no datas in a msg box should open and say "no datas

in here.

#include <string.au3>
#include <array.au3>
#include <file.au3>

$SearchDir="M:\AUTO_JOB\ALK_Daten\Tab"
$SearchFiles= "*.DAT"
$SearchFiles= "*.MAP"
$SearchFiles= "*.IND"
$SearchFiles= "*.ID"


DirRemove("M:\AUTO_JOB\Tab")
InetGet("ftp:andsoon...", "AL001_001_0000_00_GF_TB.prj",1)
Sleep(1000)

DirCreate("M:\AUTO_JOB\Tab")
ShellExecuteWait("M:\AUTO_JOB\Programm")


$FolderList=_FileListToArray($SearchDir & "M:\AUTO_JOB\Tab", $Searchfiles,1)
If (Not IsArray($FolderList)) then
MsgBox(0,"No Data in here",1)

ELSE

Run("M:\AUTO_JOB\Batch.bat")

EndIf

EndIf

Share this post


Link to post
Share on other sites

Freshprince,

The error is in your _FileListToArray($SearchDir & "M:\AUTO_JOB\Tab", $Searchfiles,1) line.

I did not notice last night that you are giving 2 paths to search - just like the filenames, you can only do one at a time! :D Do you actually want to search both the paths or just one? This is what it would look like if you wanted to search both:

For $i = 0 To 3
    ; Move through the array looking for each type in turn

    ; Look in the $SearchDir folder
    $FolderList=_FileListToArray($SearchDir, $Searchfiles[$i],1)
    ; If we find some files than set the flag)
    If IsArray($FolderList) Then $fFlag = True

    ; Look in the M:\AUTO_JOB\Tab folder
    $FolderList=_FileListToArray("M:\AUTO_JOB\Tab", $Searchfiles[$i],1)
    ; If we find some files than set the flag)
    If IsArray($FolderList) Then $fFlag = True

Next

If you only need to search one of the folders, just delete the section which looks in the other. :huggles:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Hey!

I thank you very much for that help. More important i also understand what my fault was.

Very pleased about the help,thanks to everybody!

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