Total Pageviews

Wednesday, April 2, 2014

Standard input file របស់ឡូអា

io.input() ប្រើសំរាប់បញ្ចូល standard input ហ្វាល់។ នៅពេលដែលហៅ ឈ្មោះហ្វាល់ណាមួយ វានឹងបើឈ្មោះនោះនៅក្នុង Text mode ហើយបញ្ចូល its handle ជាហ្វាល់ដើម input។ ហ្វាំងសិនមួយនេះសំរាប់ ត្រឡប់មកវិញនៅហ្វាល់ Handle ដែលទើបតែបើក ឬក៏ហ្វាល់ Current input file handle

syntax: io.input ([ file] )

ARG1(តំរូវការ) វាជា String ឬក៏ Object, ជាឈ្មោះហ្វាល់ Or File handle
សូមមើលកូដះ
local tmp = io.input()    -- save current file handle
io.input( "newfile.txt" ) -- open new file in text mode

print( io.read() )        -- read and display the file

io.input():close()        -- close the file

io.input( tmp )           -- restore the previous file

No comments:

Post a Comment