Sign in to follow this  
Followers 0
PCI

Need Help on Exiting a script and Process status Bar

12 posts in this topic

#1 ·  Posted (edited)

Hi all

I have a simple script ( Thanks to Bowmore ) that prompt user to input 2 files ( Test_file1.txt and Test_file2.txt )

It will then compare the files .

I have an issue , maybe i'm blind or need to go sleep , i cannot exit the script from the GUI ( Exit without comparing Button ) unless the compare process is completed.

Test_file1 and Test_file2 have each 1000 lines but when these files will have 20000 lines the process takes longer and you cannot exit unless the process is completed.

Could you please give me help adding a Process status Bar or when Comparing files to show how many line left to process.

Please advise.

See attached files

Thank you

Compare.au3

Test_file1.txt

Test_file2.txt

Edited by PCI

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This turns the progress bar on:

ProgressOn("Compare Files", "Comparing files...", "0% Complete")

Put that somewhere before your "compare loop" starts.

Insert ProgressSet()...

For $i = 1 To UBound($aArray1) - 1
                $iNumber = Round($i / UBound($aArray1) * 100, 2)
                ProgressSet($iNumber, $iNumber & "% Complete")
                $sID1 = StringLeft($aArray1[$i],StringInStr($aArray1[$i],"ý",1,1)-1)

This turns the progress bar off when comparing is done so put it at the end of the compare loop:

ProgressOff()

Edited by MrMitchell

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

And if you want to exit the script midprocess you should be able to do it the same way you exit the script normally using your button...

For $i = 1 To UBound($aArray1) - 1
    $iNumber = Round($i / UBound($aArray1) * 100, 2)
    ProgressSet($iNumber, $iNumber & "% Complete")
    $msg = GUIGetMsg()
    If $msg=$ConfigurationExitWithoutSaving Then
     $ExitDialog = MsgBox(36, "Are You Sure?", "Are you sure you want to exit?")
     If $ExitDialog = 6 then Exit
    EndIf

Basically you can click the button which will send the message to the GUI so you're "compare loop" will need to check that message every once in a while to see if the button was clicked.

Edited by MrMitchell

Share this post


Link to post
Share on other sites

If the comparison process now slows down too much then update the progressbar and check $msg only every n-th exection of the loop.

Something like (for n = 100):

If Mod($i, 100) Then ...

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Another thing I just noticed is that the progress bar is on top of all other windows including your GUI and and any message boxes that pop up so maybe modify the ProgressOn() function to relocate the progress bar so it's not on top of your GUI.

Share this post


Link to post
Share on other sites

Thank you MrMitchell and water for the help i'm trying all the scripts and advises you gave me.

I'll get back to you as soon as i can.

Thank you again

Share this post


Link to post
Share on other sites

Could not Run the Script properly , the script was consuming a lot of CPU 78% and also the process bar was just flickering and not normal increment.

Please advise.

Thank you

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Could not Run the Script properly , the script was consuming a lot of CPU 78% and also the process bar was just flickering and not normal increment.

Please advise.

Thank you

If you haven't already, I think you need to take Water's suggestion and implement it. Do you want to post the new code?

Edit: Here's taking into account mine and Water's methods... Compare.au3

Edited by MrMitchell

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

If you haven't already, I think you need to take Water's suggestion and implement it. Do you want to post the new code?

Edit: Here's taking into account mine and Water's methods... Compare.au3

Thank You MrMitchell and water , it did worked fine.

I forgot some coding on the script like

Dim $iNumber = 0 and so on...

Sorry

I learned few things today and yesterday thanks to you and to AIFM ( AutoIT Forum Members )

Now it's time for me to output the result for this script to Excel and intergrate the Process bar into the same GUI instead of another screen.

Thank you

Edited by PCI

Share this post


Link to post
Share on other sites

If you run into performance problems when populating Excel please post the code you use here (and the time it takes to process). There are some solutions available to speed up processing.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If you run into performance problems when populating Excel please post the code you use here (and the time it takes to process). There are some solutions available to speed up processing.

Will Do , thank you water fot the great help as usual.

Thank you

Share this post


Link to post
Share on other sites

Thanks. But I just try to do my very best ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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