Lua is not printed before the file reads

Before running the opened and read file, I encountered the problem of getting Lua to print. This will print the strings “Reading File …” and “File Read!” but only in it After finishing the getFileString() function. I want it to print “Read file…” before running. I reduced it to a file: read(“*a”) This will mess up all the prints in my (larger) script .

function getFileString(path)

local file, err = io.open(path, "r")
local all = file:read("*a")
file:close()

return all

end

function main ()

local directory = "C:\Documents and Settings\All Users\Documents\"

print("Reading File...")< br /> local file_all = getFileString(directory.."myFile.txt")
print("File Read! ")

end

main( )

It doesn’t seem to matter whether I am functional or not. I should mention that this is mainly because I am reading about 150MB files.

I think the output is just buffering. Try adding io.stdout: setvbuf(‘no’) before printing, which should turn off output buffering.

< p>Before running the opened and read file, I ran into the problem of getting Lua to print. This would print the strings “Reading File…” and “File Read!” but only after it completed the getFileString() function. Hope it prints “Read file…” before running. I reduced it to file: read(“*a”) This will mess up all prints in my (larger) script .

function getFileString(path)

local file, err = io.open(path, "r")
local all = file:read("*a")
file:close()

return all

end

function main ()

local directory = "C:\Documents and Settings\All Users\Documents\"

print("Reading File...")< br /> local file_all = getFileString(directory.."myFile.txt")
print("File Read! ")

end

main( )

It doesn’t seem to matter whether I am functional or not. I should mention that this is mainly because I am reading about 150MB files.

I think the output is just buffering. Try to add io.stdout before printing: setvbuf(‘no’), this should turn off output buffering.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3227 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.