Jump to content

Loop Problem!


Recommended Posts

First, I would like to sincerely thank everyone for the help yesterday (subject: the string and array).

Items of today I

people need help is:

I get to keep material from 1 File: Name.txt

In file Name.txt many lines are divided by characters "|" (eg : 500 Lines)

Duties of the program after 1 time period (eg 3 minutes) will read to line 2, line 3 ... n line.

That is after 1 time period the number read will be + 1

Wishes to receive the help of everyone!

Edited by WARLICHVN
Link to comment
Share on other sites

$hFile = FileOpen("Your File",0)
While 1
 $line = FileReadLine($hFile)
Sleep(18000)
Wend
FileClose($hFile)

Edited by water

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

Oh sorry, but have some problem when problem read line

eg . File : Name.txt

Name1|Addr1|PhoneNumber1
Name2|Addr2|PhoneNumber2

MyCode:

$hFile = FileOpen("Name.txt",0)
While 1
    $line = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
    MsgBox(0,"A",$line)
    Sleep(2000)
    FileClose($hFile)
Wend

So it's not read line 2

Edited by WARLICHVN
Link to comment
Share on other sites

Oh sorry, but have some problem when problem read line

eg . File : Name.txt

Name1|Addr1|PhoneNumber1
Name2|Addr2|PhoneNumber2

MyCode:

$hFile = FileOpen("Name.txt",0)
While 1
    $line = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
    MsgBox(0,"A",$line)
    Sleep(2000)
    FileClose($hFile)
Wend

So it's not read line 2

Hi,

set the FileClose ($hFile) after the Wend or use a counter e.g.

$hFile = FileOpen("Name.txt",0)
While 1
    $line = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
    MsgBox(0,"A",$line)
    Sleep(2000)
Wend
FileClose($hFile)
or

$i = 1
While 1
    $hFile = FileOpen("Name.txt",0)
    $line = FileReadLine($hFile, $i)
    If @error = -1 Then ExitLoop
    MsgBox(0,"A",$line)
    $i += 1
    Sleep(2000)
    FileClose($hFile)
Wend
Edited by 99ojo
Link to comment
Share on other sites

How to do it in Func ?

Hi,

two ways:

1st)

Global $file = "name.txt"

_ReadFile ()

Func _ReadFile ()
$hFile = FileOpen($file, 0)
While 1
    $line = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
    MsgBox(0,"A",$line)
    Sleep(2000)
Wend
FileClose($hFile)
EndFunc

or

_ReadFile ("name.txt")

Func _ReadFile ($file)
$hFile = FileOpen($file, 0)
While 1
    $line = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
    MsgBox(0,"A",$line)
    Sleep(2000)
Wend
FileClose($hFile)
EndFunc

;-))

Stefan

Edited by 99ojo
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...