Table of Contents
Scripts > fread test
Script contents// // Ask user for filename // string FileName set FileName <file.OpenDlg "txt" NULL "Text files (*.txt)|*.txt|All files (*.*)|*.*|"> if <iseq 0 <strlen FileName>> return 0 endif // // Open file // voidptr fp set fp <fopen FileName "r"> 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 <fread fp c> set s <strcat s c> else set FileDone true endif while <not FileDone> // // Write file contents (in string) to event log // echo s // // Report file length using ftell // echo <strcat <strcat "File length was " <ftell fp>> " bytes"> // // Close file // fclose fp CommentsNone. Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|