View Single Post
  #11    
Old September 30th, 2012, 10:57 AM
Umbreon's Avatar
Umbreon
Community Supporter
 
Join Date: Aug 2009
Location: Nearby my feet.
Age: 17
Gender: Male
Nature: Calm
Quote:
Originally Posted by Cilerba View Post
I'd love to make it edit actual PBS files but I have no idea how to go about doing that. This is kind of my first real program so I'm sort of learning as I go on.
Easy one:

Ruby Example:
Code:
# to retrieve
def get_item(item)
 array = IO.readlines("PBS/Items.txt")
 return array[item]
end

# to edit
def edit_item(item, data)
  array = = IO.readlines("PBS/Items.txt")
  array[item] = data
  file = File.open("PBS/Items.txt", 'wb')
  for i in 0..array.length-1
    file.write(array[i])
    file.writeln()
  end
  file.close
end
Sorry if this is wrong, but this is how I remember Ruby IOs to work. In the end run you will still need to convert the data somehow. Yes I know this is useless as of you are coding this in c++ probably, I just put it out there as an example of how the basis can go towards