Endless loop

Discussion in 'Questions (Windows Mobile)' started by Cableguy, Jun 28, 2007.

  1. Cableguy

    Cableguy Expert Licensed User

    Why does this becomes an endless loop?

    Code:
    ErrorLabel(DefaultValues)
       HiScoreTable.TableSort(
    "Score DESC")
       FileOpen(c1,
    "Pairs.ini",cWrite)
       FileWrite(c1,
    "ImageSet:"&ImageSet)
       FileWrite(c1,
    "Level:"&Level)
       FileWrite(c1,
    "")
       FileWrite(c1,
    "High-Scores:")
       FileWrite(c1,
    "")
       FileWrite(c1,HiScoreTable.Cell(
    "Player",0)&"-"&HiScoreTable.Cell("Score",0))
       FileWrite(c1,HiScoreTable.Cell(
    "Player",1)&"-"&HiScoreTable.Cell("Score",1))
       FileWrite(c1,HiScoreTable.Cell(
    "Player",2)&"-"&HiScoreTable.Cell("Score",2))
       FileWrite(c1,HiScoreTable.Cell(
    "Player",3)&"-"&HiScoreTable.Cell("Score",3))
       FileWrite(c1,HiScoreTable.Cell(
    "Player",4)&"-"&HiScoreTable.Cell("Score",4))
       FileClose(c1)
       DefaultValues:
       FileOpen(c1,
    "Pairs.ini",cWrite)
       FileWrite(c1,
    "ImageSet: Basic.ist")
       FileWrite(c1,
    "Level:Easy")
       FileWrite(c1,
    "")
       FileWrite(c1,
    "High-Scores:")
       FileWrite(c1,
    "")
       FileWrite(c1,
    "Player1-0")
       FileWrite(c1,
    "Player2-0")
       FileWrite(c1,
    "Player3-0")
       FileWrite(c1,
    "Player4-0")
       FileWrite(c1,
    "Player5-0")
       FileClose(c1)
     
  2. dzt

    dzt Active Member Licensed User

    Hi cableguy,

    In b4ppc help for ErrorLabel:
    "...Sets a label that the program will jump to in case an error will occur in the current sub..."

    If the error occurs afterDefaultValues: your program continues with the next line "FileOpen(c1,"Pairs.ini",cWrite)" and propably faces an error again and goes again to DefaultValues:



    I hope I helped

     
  3. Cableguy

    Cableguy Expert Licensed User

    Yes, I understand that but then what can be wrong?


    This is part of a sub, but is the last part of it so, I'm sure that the code is correct in its sintax....
    I added the error label after a tryout error wich render the ini file blank because it errored at the table sort as it was all cells empty, so i coded a fail-safe default value ini file creation, and that is what is failling now...:sign0161::sign0085:

    PS. I tryied reducing the defaulvalues to the simples form :

    FileOpen(c1,"Pairs.ini",cWrite)
    FileClose(c1)

    And STILL FAILS
     
    Last edited: Jun 28, 2007
  4. dzt

    dzt Active Member Licensed User

    Remove errorlabel to see the error.
    By the way did you check if pairs.ini can't be opened for write because is open by another app or something similar?
     
  5. BjornF

    BjornF Active Member Licensed User

    Dear Cableguy,

    and if you just use the FileOpen(c1,"Pairs.ini",cWrite) command?

    (i.e. is it the open or the close command that is causing the problem?)
     
  6. Cableguy

    Cableguy Expert Licensed User

    The first error to apear is the table sort since the ini file is blank the table doesnt get any values entered...
    But now it gets stranger even withou the errorlabel it loops....
    I have no other app using the file....:sign0085::sign0085::sign0085:
     
  7. Cableguy

    Cableguy Expert Licensed User

    I have some good news and some bad news...
    The good news:

    I now know why it is erroing out and DZT was Right!! the file is being used by another....Process?

    The bad news:

    WHAT PROCESS???
    I made sure to close the conection each time i access the file...

    EDIT: I changed the name of the file under the defaultvalues and now the rror descriptions talks about the c1 key being already added to the diccionary. This makes me think that the conection to c1 is still open altough i'm sure , and have double checked, I did close everytime I opened the conection...can this be a BUG????

    Edit2: defenetly a conection issue, I changed to c2 and it worked, with another filename...
     
    Last edited: Jun 28, 2007
  8. dzt

    dzt Active Member Licensed User

    Just a guess!
    On of thousands times :) you run the compiled app, it failed to terminate before closing the file and stayed as an orphan process, locking your file.

    But... only your computer's processor knows the truth.

    EDIT (about cableguy last EDIT): No it is not a bug. Just an error occured between FileOpen and FileClose and FileClose didn't executed. So the file left opened.
     
    Last edited: Jun 28, 2007
  9. Cableguy

    Cableguy Expert Licensed User

    Dzt you RULE...

    It's fixed now...

    A tip when using external files:

    It IS a good practice to CLOSE the conection you are about to use BEFORE openig it...

    Just add

    FileClose(c1) 'the conection number you'll be using
    FileOpen(c1,.........)
     
Loading...