MODULE: File manager (non-buffered file writing, excellent for logging)

Started by Monsieur OUXX, Thu 15/04/2010 20:48:39

Previous topic - Next topic

Monsieur OUXX

Hi all,

What does it do?
Here is a module that allows you to open and close files, and then manage them as "handlers" (actually integer indices).
Plus, I introduced a "non-buffered" opening mode that causes the file to be opened and closed at each writing. It's excellent when you log, because you're sure that the output is logged even if the game crashes shortly after.

Note: it's an actual implementation of my other module "Double-linked lists of unmanaged structs".
I've posted them separately because they both have their own purpose.


Current version:
1.0

Targeted version of AGS
Natively made with AGS 3.x, but can be ported very easily to 2.72 if you re-create the console's ListBox in 2.72.

Download location :
http://sourceforge.net/projects/agsh/files/

Intended audience:
     - Please read the pros and cons compared to monkey_05_06's "Stack" module in the thread devoted to my other module "Double-linked lists of unmanaged structs".
      - The idea is to be able to use Files as in/out parameters, quite quickly.

How to use it?
      - Download the file
      - Open the project. You can run it to see what it does.
      - The file "kernel.txt" contains the same output as the console.
      - Export all scripts and GUIs
      - Re-import the GUI(s)
      - Re-import the scripts and make sure that they're displayed in the same order in your project (it heavily relies on ordered dependencies)
      - If you intend to use the console :
           . Make sure you call AGSH_Console.BindGUI in the 'ongamestart' function
           . Make sure you call AGSH_Console.OnKeyPress in the 'onkeypress' function
           . Make sure you call AGSH_Console.RepeatedlyExecute in the 'repeatedlyexecute' function
      - Run AGSH_FileManager.Reset_WithDependencies in the 'ongamestart' function
      - Use AGSH_FileManager.Open,  AGSH_FileManager.Close,  AGSH_FileManager.WriteRawLine whenever you want.


Note for programers: Programming style of the module
      - It's quite heavy (you'll see it embeds many separate scripts). It's by design, for maintainability (it'll be part of a much bigger project).
      - It adopts AGS' object syntax (struct+methods), but all the methods are static. It's to be consistent with the integer indices system, and also because the very nature of this module does that it should match the "Singleton" design pattern.
      - the functions AGSH_Console.OnKeyPress and AGSH_Console.RepeatedlyExecute are called explicitely from the corresponding functions of the global script; I don't use the default functions inside the module. It's by choice. You may disable the integrated console anyway.
 

Monsieur OUXX

<Reserving this post for future potential edits of the original post>
 

SMF spam blocked by CleanTalk