====== Scripts > fread test ====== ^ Description | An example script demonstrating how to use the fopen, fread and fclose script functions. | ^ Author | [[user>Aaron]] | ^ Created | 2010/05/24 | ^ Requires | L3DT v2.9 beta 2 or later | ^ Download | {{:scripts:fread test.zs|fread test.zs}} | ===== Script contents ===== // // Ask user for filename // string FileName set FileName if > return 0 endif // // Open file // voidptr fp set fp assert fp "Cannot open file!" // // Prepare some variables // char c string s bool FileDone set FileDone false // // Read file character-by-character, and add to string // do if set s else set FileDone true endif while // // Write file contents (in string) to event log // echo s // // Report file length using ftell // echo > " bytes"> // // Close file // fclose fp ===== Comments ===== None.