WriteBoolVariableToFile

Definition

WriteBoolVariableToFile(bool value)

Description

This function writes a boolean value to the currently open file. Before writing information to the file, make sure that you have opened the desired file for writing with the OpenFileForWriting function.

Parameter

value
Specifies a boolean value to write to the currently opened file.

Example

bVar = false

function Init()
   --Create a folder in Assets/Data/ path
   CreateFolder("Lev1")

   --Create and open file to write data
   OpenFileForWriting("Lev1/level1.bin")
   WriteBoolVariableToFile(true)
   CloseFile("Lev1/level1.bin")

   --Open File to load data
   OpenFileForReading("Lev1/level1.bin")
   bVar = ReadBoolVariableFromFile()
   CloseFile("Lev1/level1.bin")
end
First, using the CreateFolder function, we create a folder called “Lev1” in the Assets/Data/ path. Then, using the OpenFileForWriting function, we open the level1.bin file located in the Assets/Data/Lev1/ path for writing. After writing the Boolean value true by the WriteBoolVariableToFile function, we close the file by the CloseFile function.
Then, using the OpenFileForReading function, we open the level1.bin file located in the path Assets/Data/Lev1/ for reading and read a boolean variable from the level1.bin file with the ReadBoolVariableFromFile() function. In our example, value of bVar is true after reading it. Finally, we close the file by the CloseFile function.
adminWriteBoolVariableToFile