Tiedostot : komennot

READINT


   KUVAUS

Lukee tiedostosta 32-bittisen kokonaisluvun. Samalla tiedosto-osoitin siirtyy neljä askelta eteenpäin.

Tulos on kokonaisluku.

   KÄYTTÖ
READINT tiedostomuuttuja

  • tiedostomuuttuja = Se muuttuja, johon tiedosto avattiin OpenToxxxx-komennolla.

  • Katso myös: WRITEINT, READBYTE, READSHORT, READFLOAT, READSTRING, READLINE

       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