Feche1320 Posted July 3, 2011 Posted July 3, 2011 Hey all, so, how can I to to read the last 100 - 150 lines of a log file? (Not the MTA log file, I have a separate archive) Thanks. www.host-ar.com.ar
karlis Posted July 3, 2011 Posted July 3, 2011 you will have to read all file, then find last 150 "\n" chars. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Feche1320 Posted July 3, 2011 Author Posted July 3, 2011 Mhh.. how? I don't understand you. www.host-ar.com.ar
karlis Posted July 3, 2011 Posted July 3, 2011 read tru all the file, and save every ~60000 bytes as string, then split the string with separator "\n"(theres some func for it), put the values in table, and then get last 150 table values. https://wiki.multitheftauto.com/wiki/Ser ... _functions https://wiki.multitheftauto.com/wiki/Cli ... _functions [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Feche1320 Posted July 3, 2011 Author Posted July 3, 2011 Yep, thanks. Another question, how can I delete a entire line on an archive and then write on it? www.host-ar.com.ar
eAi Posted July 3, 2011 Posted July 3, 2011 You basically can't, that isn't how files work, at least not without rewriting the entire file. Theoretically it's easy to truncate a file, though it doesn't appear that MTA provides access to the relevant functions to do so.
Feche1320 Posted July 4, 2011 Author Posted July 4, 2011 I was asking becouse I am a SAMP scripter too and it's possible on SAMP. www.host-ar.com.ar
Feche1320 Posted July 5, 2011 Author Posted July 5, 2011 When you do Fwrite, it overwrites the hole line, so if you had in the first line: 123456789 And then you write 'hello', it will look like this: hello And not like this: hello6789 ^-- (This is what happends to me on MTA) www.host-ar.com.ar
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now