Sign in to follow this  
Followers 0
WARLICHVN

Loop Problem!

8 posts in this topic

#1 ·  Posted (edited)

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



#2 ·  Posted (edited)

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

Thank you water!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

#5 ·  Posted (edited)

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

Thank you so much 99ojo!!!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

How to do it in Func ?

Edited by WARLICHVN

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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  
Followers 0