Sign in to follow this  
Followers 0
MadBoy

Problem with While

3 posts in this topic

#1 ·  Posted (edited)

Hello,

I encountred little problem that i can't see where it comes from. Here's a piece of code that is giving me some troubles. It's just part of code so it won't work when run but hopefully someone can analyze it. When the loop is run the first time .. it finds .7z archive just fine and unpacks first archive additionally giving output to file without problems. (will attach some log at the bottom). But when it finds another .7z archive it also seems to work fine on unpacking, but it doesn't give output back. Check the log...

_AddLineBox("Searching for 7zip archives in drivers directory (" & $path_to_drivers & ").")
        $7zip_search = FileFindFirstFile($path_to_drivers & "\*.7z")
        If $7zip_search = -1 Then
            _AddLineBox("There are no 7zip archives in " & $path_to_drivers)
            If $debug = "Yes" Then _AddLineBox("DEBUG: $path_to_drivers - " & $path_to_drivers)
            $ErrorIsThere = "Yes"
        EndIf
        While 1
            $7zip_file = FileFindNextFile($7zip_search)
            If @error Then ExitLoop
            _AddLineBox("Unpacking drivers from " & $path_to_drivers & "\" & $7zip_file)
            $7zip_unpack = $7zip & " x -y -aos " & $path_to_drivers & "\" & $7zip_file & " -o" & $copy_where
            If $debug = "Yes" Then _AddLineBox("DEBUG: $7zip_unpack - " & $7zip_unpack)
            $drivers_unpack = Run(@ComSpec & " /c " & $7zip_unpack, "", @SW_HIDE,2)
            While 2
                $drivers_data = StdoutRead($drivers_unpack)
                If @error Then ExitLoop
                If $drivers_data Then
                    $drivers_output &= $drivers_data
                Else
                    Sleep(10)
                EndIf
            WEnd
            $drivers_output = StringStripWS($drivers_output, 6); Remove spaces from output
            $drivers_output = StringSplit($drivers_output, @CRLF); Split output of 7zip backup packing into array
            If $debug = "Yes" Then
                For $a = 1 To $drivers_output[0]
                    _AddLineBox("DEBUG: " & $drivers_output[$a])
                Next
            EndIf
        WEnd
        FileClose($7zip_search)

[14:32:46]- Searching for 7zip archives in drivers directory (C:\Test).

[14:32:46] - Unpacking drivers from C:\Test\DP_Chipset_wnt5_x86-32_605.7z

[14:32:46] - DEBUG: $7zip_unpack - C:\DOCUME~1\ADMINI~1\USTAWI~1\Temp\7z.exe x -y -aos C:\Test\DP_Chipset_wnt5_x86-32_605.7z -oC:\DriversTest

[14:32:51] - DEBUG Output:

[14:32:51] - DEBUG Output: 7-Zip 4.42 Copyright © 1999-2006 Igor Pavlov 2006-05-14

[14:32:51] - DEBUG Output: Processing archive: C:\Test\DP_Chipset_wnt5_x86-32_605.7z

[14:32:51] - DEBUG Output: Extracting D

[14:32:51] - DEBUG Output: Extracting D\C

[14:32:51] - DEBUG Output: Extracting D\C\A

14:32:56] - DEBUG Output: Extracting D\C\V\VIAIRDA1.SYS

[14:32:56] - DEBUG Output: Everything is Ok

[14:32:56] - Unpacking drivers from C:\Test\DP_LAN_wnt5_x86-32_6051.7z

[14:32:56] - DEBUG: $7zip_unpack - C:\DOCUME~1\ADMINI~1\USTAWI~1\Temp\7z.exe x -y -aos C:\Test\DP_LAN_wnt5_x86-32_6051.7z -oC:\DriversTest

[14:33:14] - DEBUG Output: 1

[14:33:14] - Unpacking drivers from C:\Test\DP_MassStorage_wnt5_x86-32_6031.7z

[14:33:14] - DEBUG: $7zip_unpack - C:\DOCUME~1\ADMINI~1\USTAWI~1\Temp\7z.exe x -y -aos C:\Test\DP_MassStorage_wnt5_x86-32_6031.7z -oC:\DriversTest

[14:33:29] - DEBUG Output: 1

Hopefully someone can look on it from fresh side. I've been looking at it for too long. Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

did you try "clearing" the variables

While 1

$drivers_data = ""

$drivers_output = ""

$drivers_unpack = ""

etc.. etc..

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

did you try "clearing" the variables

While 1

$drivers_data = ""

$drivers_output = ""

$drivers_unpack = ""

etc.. etc..

8)

I thought about it at night, and now you suggest it ;P and Yes it works now :P Tnx!


My little company: Evotec (PL version: Evotec)

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