Sign in to follow this  
Followers 0
onedayillpay

loop lost its track

2 posts in this topic

varry simple loop.

so every time the loop reach 1000 then play a sound and then start back from one.

after about the 3erd loop the file write does not keep writing. the file goes blank and i dont know why.

if you open the ini file right as you start the script you can see the data is writen to the file but then lost its track.

$number = 1
FileOpen("numberListen.ini", 2)
FileWrite("numberListen.ini",$number)
While 1
FileOpen("numberListen.ini", 2)
    if $number = 1000 Then
        SoundPlay(@WindowsDir & "\media\tada.wav",1)
        $number = 1
        Else
    FileWrite("numberListen.ini",$number)
    $number = $number +1
    Sleep(100)
EndIf
WEnd
FileWrite("numberListen.ini",$number)
FileClose("numberListen.ini")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Get your fileopen out of the loop. Remove it entirely.

$number = 1
$file = FileOpen("numberListen.TXT", 2)
FileWrite($file, $number)
While 1
    If $number = 1000 Then
        SoundPlay(@WindowsDir & "\media\tada.wav", 1)
        $number = 1
    Else
        FileWrite($file, $number)
        $number += 1
        Sleep(100)
    EndIf
WEnd
; anything after this loop is moot...there's no break condition
; but if there was:

FileWrite($file, $number)
FileClose($file)
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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