Sign in to follow this  
Followers 0
RexRomae

Count element of an array

12 posts in this topic

#1 ·  Posted (edited)

Hello everybody, I have a problem with this script, I want know how many elements there are in an array?

enjoy my script!

CODE
#include <Array.au3>

#include <IE.au3>

; Autore: Rex Romae

$search_tmp = FileFindFirstFile("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")

$search_exe = FileFindFirstFile("C:\Documents and Settings\Administrator\*.exe")

While 1

$file_tmp = FileFindNextFile($search_tmp)

$file_exe = FileFindNextFile($search_exe)

If @error Then ExitLoop

MsgBox(0,"FileControll: Avviso!","Sono stati trovati: NUMBER OF FILES FIND, saranno subito eliminati!")

;FileDelete("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")

;FileDelete("C:\Documents and Settings\Administrator\*.exe")

WEnd

FileClose($search_tmp)

FileClose($search_exe)

Edited by RexRomae

Share this post


Link to post
Share on other sites



Hi,

Ubound?

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

so? $u = Ubound($search_tmp)

When I print $u in a MsgBox its repeat for the numbers of elements and it prints 0! Are you understanding?

U can try!

Edited by RexRomae

Share this post


Link to post
Share on other sites

You don't even have an array in your script. Use _FileListToArray, its in the help file.

Share this post


Link to post
Share on other sites

_FileListToArray give me back an array right??

Share this post


Link to post
Share on other sites

_FileListToArray give me back an array right??

That's right

Using Your origional code (no array used) Then you could also add a variable

#include <Array.au3>
#include <IE.au3>
; Autore: Rex Romae
$f_Count = 0
$search_tmp = FileFindFirstFile("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")
$search_exe = FileFindFirstFile("C:\Documents and Settings\Administrator\*.exe")
While 1
$file_tmp = FileFindNextFile($search_tmp)
$file_exe = FileFindNextFile($search_exe)
If @error Then ExitLoop
$f_Count += 1
MsgBox(0,"FileControll: Avviso!","Sono stati trovati: NUMBER OF FILES FIND, saranno subito eliminati!")
;FileDelete("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*") 
;FileDelete("C:\Documents and Settings\Administrator\*.exe")
WEnd
FileClose($search_tmp) 
FileClose($search_exe)
MsgBox(0, "Found", $f_Count & " files have been found")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Thank you, now I have this...It find only 1 file, why??

CODE
#include <Array.au3>

#include <IE.au3>

$f_Count_tmp = 0

$f_Count_exe = 0

$search_tmp = FileFindFirstFile("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")

$search_exe = FileFindFirstFile("C:\Documents and Settings\Administrator\*.exe")

While 1

$file_tmp = FileFindNextFile($search_tmp)

$file_exe = FileFindNextFile($search_exe)

If @error Then ExitLoop

$f_Count_tmp += 1

$f_Count_exe += 1

FileDelete("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")

FileDelete("C:\Documents and Settings\Administrator\*.exe")

WEnd

FileClose($search_tmp)

FileClose($search_exe)

MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_tmp &" files jar_cache infetti, sono stati eliminati!")

MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_exe &" files exe pericolosi, sono stati eliminati!")

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thank you, now I have this...It find only 1 file, why??

CODE
#include <Array.au3>

#include <IE.au3>

$f_Count_tmp = 0

$f_Count_exe = 0

$search_tmp = FileFindFirstFile("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")

$search_exe = FileFindFirstFile("C:\Documents and Settings\Administrator\*.exe")

While 1

$file_tmp = FileFindNextFile($search_tmp)

$file_exe = FileFindNextFile($search_exe)

If @error Then ExitLoop

$f_Count_tmp += 1

$f_Count_exe += 1

FileDelete("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")

FileDelete("C:\Documents and Settings\Administrator\*.exe")

WEnd

FileClose($search_tmp)

FileClose($search_exe)

MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_tmp &" files jar_cache infetti, sono stati eliminati!")

MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_exe &" files exe pericolosi, sono stati eliminati!")

For openers that whole While loop is messed up. You are only checking @Error for $file_exe. There are two better methods to use. The first would be to create 2 arrays using _FileListToArray() and then 2 loops to handle the files.

The other is to just create 2 Loops. One for each FileFindNextFile(). The following should be close.

#include <Array.au3>
#include <IE.au3>

$f_Count_tmp = 0
$f_Count_exe = 0

$search_tmp = FileFindFirstFile("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")
While 1
    $file_tmp = FileFindNextFile($search_tmp)
    If @error Then ExitLoop
        $f_Count_tmp += 1
        FileDelete($File_tmp)
WEnd
FileClose($search_tmp)
$search_exe = FileFindFirstFile("C:\Documents and Settings\Administrator\*.exe")
While 1
    $file_exe = FileFindNextFile($search_exe)
    If @error Then ExitLoop
        $f_Count_exe += 1
        FileDelete("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")
        FileDelete($File_Exe)
WEnd
FileClose($search_exe)
MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_tmp &" files jar_cache infetti, sono stati eliminati!")
MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_exe &" files exe pericolosi, sono stati eliminati!")
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

also thanks, I have put it in auto-execution and when I start windows it works, but during the time it doesn't work! I want that It always working, how do I make it? thanks

Share this post


Link to post
Share on other sites

also thanks, I have put it in auto-execution and when I start windows it works, but during the time it doesn't work! I want that It always working, how do I make it? thanks

If you mean that you never want the file to exit then do this. (not recommended)

#include <Array.au3>
#include <IE.au3>
While 1
$f_Count_tmp = 0
$f_Count_exe = 0

$search_tmp = FileFindFirstFile("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")
While 1
    $file_tmp = FileFindNextFile($search_tmp)
    If @error Then ExitLoop
        $f_Count_tmp += 1
        FileDelete($File_tmp)
WEnd
FileClose($search_tmp)
$search_exe = FileFindFirstFile("C:\Documents and Settings\Administrator\*.exe")
While 1
    $file_exe = FileFindNextFile($search_exe)
    If @error Then ExitLoop
        $f_Count_exe += 1
        FileDelete("C:\Documents and Settings\Administrator\Impostazioni locali\Temp\jar_cache*.*")
        FileDelete($File_Exe)
WEnd
FileClose($search_exe)
MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_tmp &" files jar_cache infetti, sono stati eliminati!")
MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_exe &" files exe pericolosi, sono stati eliminati!")
Wend

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Why not recommended? opsss with your script the loop don't have finish :)

I have edit it, but I would want that the script is always ON and that it show the MsgBox only if the exe or jar_cache are presents! I don't succeed :)

Edited by RexRomae

Share this post


Link to post
Share on other sites

Why not recommended? opsss with your script the loop don't have finish :)

I have edit it, but I would want that the script is always ON and that it show the MsgBox only if the exe or jar_cache are presents! I don't succeed :)

If $f_Count_tmp > 0 Then MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_tmp &" files jar_cache infetti, sono stati eliminati!")

If $f_Count_exe > 0 Then MsgBox(0,"FileControll: Avviso!","Sono stati trovati: "& $f_Count_exe &" files exe pericolosi, sono stati eliminati!")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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