How will you save a program in Small Basic?
Answers
Explanation:
save and open settings across multiple sessions of your program.
Properties
LastError
File.LastError
Gets or sets the last encountered file operation based error message. This property is useful for finding out when some method fails to execute.
Operations
ReadContents
File.ReadContents(filePath)
Opens a file and reads the entire file's contents. This method will be fast for small files that are less than an MB in size, but will start to slow down and will be noticeable for files greater than 10MB.
filePath
The full path of the file to read. An example of a full path will be c:\temp\settings.data.
Returns
The entire contents of the file.
WriteContents
File.WriteContents(filePath, contents)
Opens a file and writes the specified contents into it, replacing the original contents with the new content.
filePath
The full path of the file to write to. An example of a full path will be c:\temp\settings.data.
contents
The contents to write into the specified file.
Returns
If the operation was successful, this will return "SUCCESS". Otherwise, it will return "FAILED".
ReadLine
File.ReadLine(filePath, lineNumber)
Opens the specified file and reads the contents at the specified line number.
filePath
The full path of the file to read from. An example of a full path will be c:\temp\settings.data.
lineNumber
The line number of the text to be read.
Returns
The text at the specified line of the specified file.
WriteLine
File.WriteLine(filePath, lineNumber, contents)
Opens the specified file and write the contents at the specified line number. This operation will overwrite any existing content at the specified line.
filePath
The full path of the file to read from. An example of a full path will be c:\temp\settings.data.
lineNumber
The line number of the text to write.
contents
The contents to write at the specified line of the specified file.
Returns
If the operation was successful, this will return "SUCCESS". Otherwise, it will return "FAILED".
InsertLine
File.InsertLine(filePath, lineNumber, contents)
Opens the specified file and inserts the contents at the specified line number. This operation will not overwrite any existing content at the specifid line.
filePath
The full path of the file to read from. An example of a full path will be c:\temp\settings.data.