Jump to content

Progress bar in For loop


Recommended Posts

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!!!

Link to comment
Share on other sites

And your question is?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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...

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...