Total Pageviews

Thursday, April 3, 2014

តួនាទីរបស់ OutPut ម្តងមើល

io.output()
នេះហ្វាល់ដើមរបស់ ​​output គឺ stdout ដែលវាដូចគ្នានឹង ​io.input ប៉ុន្តែគ្រានតែប្រតិបត្តលើ ហ្វាល់ដើម ​​OUTPUT FILES។ សំរាប់ហ្វាំងសិនមួយនេះនឹងត្រឡប់ជា ​​​​​file handle របស់ហ្វាល់ ដែលទើបតែបើក ឬក៏ handle current input file handle

Syntax: io.output ([file])

File(ជំរើស) វាជា String Or Object ជាឈ្មោះរបស់ហ្វាល់ ឬក៏ហ្វាល់ ហេនឌល់
សូមមើលកូដះ
local tmp = io.output()    -- save current file handle
local path = system.pathForFile( "newFile.txt", system.DocumentsDirectory  )
io.output( path )  -- open new file in text mode
io.write( "My real data" ) -- write the file
io.output():close()        -- close the file

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

No comments:

Post a Comment