Total Pageviews

Friday, April 4, 2014

io.write() នេះជា IO ចុងក្រោយរបស់ឡូអា


គេប្រើសំរាប់សរសេរ តំលៃគ្រប់ its argument ទៅកាន់ហ្វាល់។ វាត្រូវតែជា​ String Or Numbers ដើម្បីសរសេរតំលៃផ្សេង សូមប្រើ tostring() or string.format() មុនពេលសរសេរ។ នៅក្នុង ម៉ូដធម្មតាហ្វាំងសិននេះ សរសេរទៅកាន់ standard output (stdout) ដែលជាហ្វាល់ដើមរបស់ Corona terminal បើសិនជា io.output() មិនត្រូវបានហៅជាឈ្មោះ។ វាស្មើនឹង io.output():write
និយាយដោយខ្លី print() ប៉ុន្តែសំរាប់​new line character (\n) is appended ទៅកាន់ output string
បើសិនជាអ្នកចង់សរសេរហ្វាល់ទិន្នន័យទៅកាន់ហ្វាល់មួយនោះគឺ file:write() ដែលត្រូវប្រើ ជំនួស io.write()
សំរាប់ហេតុផលសុវត្ថិភាព សូមកុំសរសេរហ្វាល់ទៅកាន់ system.ResourceDirectory (the directory where the application is stored) សូមប្រើដោយច្បាស់លាស់ system.DocumentsDirecoty, system.TemporaryDirecoty or system.cachesDirectory ដែលជា parameter នៅក្នុង system.pathForFile() ហ្វាំងសិននៅពេលបើកហ្វាល់សំរាប់សរសេរ។​ សូមមើល io.open() for detail

Syntax: io.write ( arg1 [, arg2] [,…])


Arg1, arg2 (ជំរើស) វាជា String Or Number អាចជា ​one or more string or number arguments (Separate by commas)

No comments:

Post a Comment