Uncorrectly read file - Printable Version +- NaaLaa (https://www.naalaa.com/forum) +-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html) +--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html) +--- Thread: Uncorrectly read file (/thread-109.html) |
Uncorrectly read file - 1micha.elok - 03-23-2024 Question Case 1 : I think ... [for...next] is not the best way to read text file Case 2 : I think this is the best way, but [do..until frln(f) = "unset"] gives unexpectedly output Please advice me what is the best way to read the whole text file ? Thank you. Code: set window "readfile",400,400 RE: Uncorrectly read file - Marcus - 03-23-2024 Like this, maybe: Code: f = openfile("story.txt") Or: Code: ' contains a bunch of helper functions related to files. RE: Uncorrectly read file - Tomaaz - 03-23-2024 Code: text = system("type story.txt") RE: Uncorrectly read file - Marcus - 03-23-2024 (03-23-2024, 02:28 PM)Tomaaz Wrote: Nice! I've never used that command And if you want to split it into an array of lines: Code: lines = split(system("type story.txt"), chr(10)) RE: Uncorrectly read file - 1micha.elok - 03-24-2024 Thank you Tomaaz and Marcus for the solution. Let me code it in this way : Code: '================================== RE: Uncorrectly read file - Tomaaz - 03-24-2024 Why not Code: wln system("type story.txt") ? It will print the entire file. What's the point of splitting? RE: Uncorrectly read file - 1micha.elok - 03-24-2024 comparison using split() and without split() function click the image to zoom in |