Jump to content
Sign in to follow this  
vmorais

String of Numbers in array index value

Recommended Posts

vmorais

Hi there..

My script goes search every folder name in ScriptDir and inside those, it will search for folders with name like A*.*

Everything is OK if folders name is not just numbers, if it is.. nothing is listed in .xls

I know the problem is related to my dynamic variables in the array index but i can't figure it out, can you help me??

Thanks!

here is my code..

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

Dim $final[1]
Dim $versoes[1]


$pastas = _FileListToArray(@ScriptDir, "*.*", 2)
$nlinhas = _ArrayMax($pastas)
$ficheiro = @ScriptDir & "\trace.bat"
$lista = @ScriptDir & "\lista.xls"


If Not FileExists(@ScriptDir &"\default.bat") Then
    MsgBox(0+48, "Erro!", "Ficheiro default.bat não existe, a aplicação vai fechar.")
    Exit
EndIf

For $i = 1 to $nlinhas step +1
    $x = $i
        
    If FileExists(@ScriptDir &"\" &$pastas[$x] &"\Bin\titre.trs") Then
            FileCopy(@ScriptDir &"\" &$pastas[$x] &"\Bin\Titre.trs", @ScriptDir &"\" &$pastas[$x] &"\" &$pastas[$x] &".trs")
        
        $temp = _FileListToArray(@ScriptDir &"\" &$pastas[$x], "A*.*", 2)
    
        _ArrayInsert($final,$x,'ren ' &'"'& @ScriptDir & "\" &$pastas[$x] & '\' &$pastas[$x] &'.trs' &'" ' &$pastas[$x] &'-' &$temp[1] &'.trs')
        _ArrayInsert($final, $x, 'echo ren ' &'"'& @ScriptDir & "\" &$pastas[$x] & '\' &$pastas[$x] &'.trs' &'" ' &$pastas[$x] &'-' &$temp[1] &'.trs' &" >> trace.log")
        
        If Not FileExists(@Scriptdir &"\" &$pastas[$x] &"\" &$pastas[$x] &'-' &$temp[1] &'.trs')  Then
            _ArrayInsert($versoes, $x, $pastas[$x] &"   " &$temp[1] &"  " &"FALTA MOVER FICHEIRO")
        Else
            FileOpen(@Scriptdir &"\" &$pastas[$x] &"\" &$pastas[$x] &'-' &$temp[1] &'.trs', 0)
        $versao = FileReadLine(@ScriptDir &"\" &$pastas[$x] &"\" &$pastas[$x] &'-' &$temp[1] &'.trs', 6)
        _ArrayInsert($versoes, $x, $pastas[$x] &"   " &$temp[1] &"  " &$versao)
        
        EndIf
    
    If Not FileExists(@ScriptDir &"\" &$pastas[$x] &"\Bin\titre.trs")  Then
        _ArrayDelete($pastas, $x)
    EndIf
    
    EndIf
    If $i = 0 Then
            _ArrayPop($final)
        
    EndIf
Next

If FileExists(@ScriptDir &"\trace.bat") Then
    FileDelete(@ScriptDir &"\trace.bat")
EndIf


_ArrayDelete($final, 0)
_ArrayDelete($versoes, 0)

FileCopy(@ScriptDir &"\default.bat", @ScriptDir &"\trace.bat")
$x_ficheiro = FileOpen($ficheiro, 1) ; 1 = append

    _FileWriteFromArray($x_ficheiro, $final)
    FileWrite($x_ficheiro, @CRLF &":end")
    FileWrite($x_ficheiro, @CRLF &"exit")
    FileClose($x_ficheiro)

    _FileWriteFromArray($lista, $versoes)
    _FileWriteToLine($lista, 1, "VERSOES TEAMS",1)

ShellExecuteWait($lista)
ShellExecuteWait($ficheiro)

For $i = 1 to $nlinhas step +1
    $x = $i
    FileDelete(@ScriptDir &"\" &$pastas[$x] &"\" &$pastas[$x] &".trs")
 Next

;_ArrayDisplay($final, "final")
;_ArrayDisplay($pastas, "pastas")
;_ArrayDisplay($versoes, "versoes")

Share this post


Link to post
Share on other sites
PsaltyDS

My script goes search every folder name in ScriptDir and inside those, it will search for folders with name like A*.*

Everything is OK if folders name is not just numbers, if it is.. nothing is listed in .xls

I don't understand. If you are searching on "A*.*" how could a name consisting of all numbers match that?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
vmorais

I don't understand. If you are searching on "A*.*" how could a name consisting of all numbers match that?

:)

The problem is not in that array but with $pastas = _FileListToArray(@ScriptDir, "*.*", 2)

Share this post


Link to post
Share on other sites
PsaltyDS

The problem is not in that array but with $pastas = _FileListToArray(@ScriptDir, "*.*", 2)

I'm not seeing the problem:
#include <File.au3>
#include <Array.au3>

For $n = 1 To 5
    DirCreate(@ScriptDir & "\" & String($n))
    DirCreate(@ScriptDir & "\" & String($n * 11))
    DirCreate(@ScriptDir & "\" & String($n * 111))
    DirCreate(@ScriptDir & "\" & String($n * 1111))
    DirCreate(@ScriptDir & "\" & String($n * 1111) & "." & String($n * 111))
Next

$pastas = _FileListToArray(@ScriptDir, "*.*", 2)
_ArrayDisplay($pastas, "$pastas")

For $n = 1 To 5
    DirRemove(@ScriptDir & "\" & String($n))
    DirRemove(@ScriptDir & "\" & String($n * 11))
    DirRemove(@ScriptDir & "\" & String($n * 111))
    DirRemove(@ScriptDir & "\" & String($n * 1111))
    DirRemove(@ScriptDir & "\" & String($n * 1111) & "." & String($n * 111))
Next

What do the folder names being missed look like? Are you sure they are directly under @ScriptDir?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
vmorais

I'm not seeing the problem:

What do the folder names being missed look like? Are you sure they are directly under @ScriptDir?

:)

If i have a folder just with numbers, the other ones are not listed too.

In atachment there is my script with a sample of folders, if you run it, it is ok. If you create a folder "1234" per example, it doesn't.

Trace_TRS.zip

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.