Tiedostot : komennot

WRITEINT


   KUVAUS

Kirjoittaa tiedostoon 32-bittisen kokonaisluvun. Samalla tiedosto-osoitin siirtyy neljä askelta eteenpäin.

Kirjoitettu arvo on kokonaisluku väliltä -2 147 483 647 ja 2 147 483 647.

   KÄYTTÖ
WRITEINT tiedostomuuttuja, arvo

  • tiedostomuuttuja = Se muuttuja, johon tiedosto avattiin OpenToxxxx-komennolla.
  • arvo = Mielellään kokonaisluku.

  • Katso myös: READINT, WRITEBYTE, WRITESHORT, WRITEFLOAT, WRITESTRING, WRITELINE

       ESIMERKKI
    x=200
    y=150

    AddText "Use arrows to move"
    AddText "F1=save game"
    AddText "F2=load game"

    Repeat

        If KeyHit(cbkeyf1) Then GoSub savegame
        If KeyHit(cbkeyf2) Then GoSub loadgame

        If LeftKey() Then x-1
        If RightKey() Then x+1
        If UpKey() Then y-1
        If DownKey() Then y+1

        Box x,y,10,10

        DrawScreen

    Until EscapeKey()
    End

    'This sub-program will save game
    savegame:

        f=OpenToWrite("Media\simpleSave.dat")
        
            WriteInt f,x
            WriteInt f,y
        
        CloseFile f
        
    Return

    'This sub-program will load game
    loadgame:

        f=OpenToRead("Media\simpleSave.dat")
        
            x=ReadInt(f)
            y=ReadInt(f)
        
        CloseFile f
        
    Return

    <<TAKAISIN