Jump to content
Sign in to follow this  
WARLICHVN

Loop Problem!

Recommended Posts

WARLICHVN

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

Share this post


Link to post
Share on other sites
water

$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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
WARLICHVN

Thank you water!

Share this post


Link to post
Share on other sites
WARLICHVN

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

Share this post


Link to post
Share on other sites
99ojo

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

Share this post


Link to post
Share on other sites
WARLICHVN

Thank you so much 99ojo!!!

Share this post


Link to post
Share on other sites
WARLICHVN

How to do it in Func ?

Edited by WARLICHVN

Share this post


Link to post
Share on other sites
99ojo

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

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  

×