Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 13 14 15 16 17 18 Next »
reading and writing to a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
reading and writing to a file
27-06-2015, 11:31 AM,
#3
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: reading and writing to a file
The reason your print is yielding nothing is because you're not telling it what to read. If you want to read the entire file, then you use:
io.input(_savedCrewFile)
print(io.read("*a"))

The valid input parameters to read are:
  • *a - Read the rest of the file from where you're currently at.
  • *n - Reads a number.
  • *l - Reads a line without the new line character.
  • *L - Reads a line with the new line character.
  • Number - Reads the given number of bytes.

You can combine them in any way, for example:
local FirstLine, SecondLine, RestOfFile = io.read( "*l", "*l", "*a" )
This would read the first two lines (without including the new line characters), then the rest of the file.

LocInt: You don't need that complicated setup. Just open the file in append mode from the start if you want to append. It will create the file if it does not exist.
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
reading and writing to a file - by shinji144 - 27-06-2015, 01:12 AM
RE: reading and writing to a file - by LocInt - 27-06-2015, 10:10 AM
RE: reading and writing to a file - by Red The Blue Color - 28-06-2015, 07:03 AM
RE: reading and writing to a file - by Person8880 - 27-06-2015, 11:31 AM
RE: reading and writing to a file - by LocInt - 27-06-2015, 11:32 AM
RE: reading and writing to a file - by Person8880 - 27-06-2015, 11:38 AM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.