Jump to content

loop lost its track


Recommended Posts

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

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

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