Sign in to follow this  
Followers 0
tempman

Progress bar in For loop

14 posts in this topic

Hi,

I want to put Progress bar in For loop

#include <File.au3>

$message = "Open Log file..."

$PATH = FileOpenDialog($message, @WorkingDir & "\", "Log (*.log)", 1 + 4 )
If @error Then Exit

$search = InputBox("Search", "What to serch for", "")

$FILE = FileOpen($PATH, 0)

For $INDEX = 1 To _FileCountLines($PATH)
$LINE = FileReadLine($FILE,$INDEX)
$FIND = StringInStr($LINE,$search)
If Not @error And $FIND <> 0 Then MsgBox(48,"Found!",$LINE)
Next

FileClose($FILE)

MsgBox(64, "Search", "Finished!")

Exit

Heed help, cheers!!!

Share this post


Link to post
Share on other sites



And your question is?


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

where to to put Progress bar in code to script work properly?

Share this post


Link to post
Share on other sites

Check functions ProgressSet, ProgressOn and ProgressOff in the help file. The example scripts there show you what to do.


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

I already done that, but since file size is larger than 500kb the progress bar doesn't work correctly

Share this post


Link to post
Share on other sites

Can you post the code you have (including the failing progressbar)?


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

#include <File.au3>

$message = "Open Log file..."

$PATH = FileOpenDialog($message, @WorkingDir & "\", "Log (*.log)", 1 + 4 )
If @error Then Exit

$search = InputBox("Search", "What to serch for", "")

$Form          =  GUICreate("GUI",450,200)
$progressbar    =  GUICtrlCreateProgress(10, 150, 430, 20)
GUISetState(@SW_SHOW)

$FILE = FileOpen($PATH, 0)
For $INDEX = 1 To _FileCountLines($PATH)
    $LINE = FileReadLine($FILE,$INDEX)
    $FIND = StringInStr($LINE,$search)
    If Not @error And $FIND <> 0 Then MsgBox(48,"Found!",$LINE)
    GUICtrlSetData($progressbar,$INDEX)
Next
FileClose($FILE)

MsgBox(64, "Search", "Finished!")

Exit

I know this is wrong so i didn't publish it at the first place...

Share this post


Link to post
Share on other sites

You have to specify percent so the script should look like:

#include <File.au3>

$message = "Open Log file..."

$PATH = FileOpenDialog($message, @WorkingDir & "", "Log (*.log)", 1 + 4)
If @error Then Exit

$search = InputBox("Search", "What to serch for", "")

$Form = GUICreate("GUI", 450, 200)
$progressbar = GUICtrlCreateProgress(10, 150, 430, 20)
GUISetState(@SW_SHOW)

$FILE = FileOpen($PATH, 0)
$iRecords = _FileCountLines($PATH)
For $INDEX = 1 To $iRecords
    $LINE = FileReadLine($FILE, $INDEX)
    $FIND = StringInStr($LINE, $search)
    If Not @error And $FIND <> 0 Then MsgBox(48, "Found!", $LINE)
    GUICtrlSetData($progressbar, Int($iRecords * 100 / $INDEX))
Next
FileClose($FILE)

MsgBox(64, "Search", "Finished!")

Exit

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

#9 ·  Posted (edited)

With all due respect, this not working :

Progress bar went from 0-100% less than a second..

This app need to work on xp intel celeron 2.4ghz

Edited by tempman

Share this post


Link to post
Share on other sites

I see. But this works - tested ;)

#include <File.au3>

$message = "Open Log file..."

$PATH = FileOpenDialog($message, @WorkingDir & "", "Log (*.log)", 1 + 4)
If @error Then Exit

$search = InputBox("Search", "What to serch for", "")

ProgressOn("Searching Log Files", "Log File: " & $PATH)
$FILE = FileOpen($PATH, 0)
$iRecords = _FileCountLines($PATH)
For $INDEX = 1 To $iRecords
    $LINE = FileReadLine($FILE, $INDEX)
    $FIND = StringInStr($LINE, $search)
    If Not @error And $FIND <> 0 Then MsgBox(48, "Found!", $LINE)
    $percent = Int(($INDEX * 100) / $iRecords)
    ProgressSet($percent, $percent & "%")
Next
ProgressOff()
FileClose($FILE)

MsgBox(64, "Search", "Finished!")

Exit

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

Yes, thank you for this, but Progress bar is always on top, so when message box appears it is behind Progress bar.

Can that be fixed?

Cheers!

Share this post


Link to post
Share on other sites

Sure:

#include <File.au3>

$message = "Open Log file..."

$PATH = FileOpenDialog($message, @WorkingDir & "", "Log (*.log)", 1 + 4)
If @error Then Exit

$search = InputBox("Search", "What to serch for", "")

ProgressOn("Searching Log Files", "Log File: " & $PATH, "", default, (@DesktopHeight/2)-250, 2)
$FILE = FileOpen($PATH, 0)
$iRecords = _FileCountLines($PATH)
For $INDEX = 1 To $iRecords
    $LINE = FileReadLine($FILE, $INDEX)
    $FIND = StringInStr($LINE, $search)
    If Not @error And $FIND <> 0 Then MsgBox(48, "Found!", $LINE)
    $percent = Int(($INDEX * 100) / $iRecords)
    ProgressSet($percent, $percent & "%")
Next
ProgressOff()
FileClose($FILE)

MsgBox(64, "Search", "Finished!")

Exit


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

#13 ·  Posted (edited)

Cheers mate!!!

I find also this:

262144 MsgBox has top-most attribute set 0x40000

so if this:

If Not @error And $FIND <> 0 Then MsgBox(48, "Found!", $LINE)

change to this:

If Not @error And $FIND <> 0 Then MsgBox(262144, "Found!", $LINE)

problem is also solved!

Thank you for your time...

Edited by tempman

Share this post


Link to post
Share on other sites
:D

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