All pastes #235373 Raw Edit

Rick

public c v1 · immutable
·published 2006-11-03 05:17 UTC
rendered paste body
import File;import Trex;class CDataReader{	array& blocks;		method CDataReader()	{		this.blocks = new array;	}		method long loadFile(string fileName)	{		File file;				file = new File(fileName, 0);				if (file.Open() != 0)		{			return false;		}				long ready = false;		list& block = new list();				while (file.Eof() == false)		{			string line = "";						file.ReadTextLine(line);						line = line.Trim();						if (ready == false)			{				if (line.length == 0)				{					continue;				}								if (line == "*BEGIN*")				{					ready = true;				}								continue;			}						if (line.length == 0 || line == "*END*")			{				if (block.length > 0)				{					this.blocks += block;					& block = new list();				}								if (line == "*END*")				{					break;				}								continue;			}						if (line.BeginsWith("/") == true || line.BeginsWith("=") == true)			{				continue;			}						long pos = line.FindString(":=", 0);						if (pos == -1)			{				continue;			}						string name = line.SubString(0, pos).Trim();			string value = line.SubString(pos + 2, line.length - pos - 2).Trim();						block.Add(name, value);		}				return true;	}}