File records
Writing a file record
To use file records file record have to be created first. Keep in mind that file record is saved in flash memory so after restart file record information is still available. In case you want overwrite file then format record firstly or check that record file created successfully. Keep in mind that all records are formatted with one function. When new record has been created information could be written to a file record. After writing information a file record has to be closed:
Creating file record
new array_save1[12]=''save this 1'';
new array_save2[12]=''save this 2'';
new status;
main(){
File_Records(Format); //erase all records
File_Records(FILE_1, Create_File, "data_record1.bin"); //create file record
File_Records(FILE_1, Write_File, array_save1, sizeof array_save1); // write data
File_Records(FILE_1, Close_File); // close file
File_Records(Format); // format to create new record in FILE_1
File_Records(FILE_1, Create_File, "data_record2.bin"); // create record
File_Records(FILE_1, Write_File, array_save2, sizeof array_save2); // write data
File_Records(FILE_1, Close_File); // close file
status=File_Records(FILE_1, Create_File, "data_record3.bin"); // create record
if(status==0){ // check report
File_Records(Format); // erase all records
File_Records(FILE_1, Create_File, "data_record3.bin"); // create record
}
while(1){
Delay(1000);
}
}
Reading a file record
When we do not know length of record or length is variable we could read length firstly. Keep in mind that array length must be bigger than record length. If file name gives information like date or event it could be read too:
Writing to a file record
new array_load[12];
new record_length;
new record_name[12];
main(){
record_length = File_Records(FILE_1, Length_File); // to find out record length
File_Records(FILE_1, Read_File, 0, record_length, array_load); // read record information
File_Records(FILE_1, Read_File_Name, 0, 20, record_name); // read record name
while(1){
Delay(1000);
}
}