How to use the datafile (database) object

Free BrownRecluse scripts provided by SoftByte Labs and users. To use, copy the script and paste it in the BrownRecluse script editor. Modify to your need, save and run.
Post Reply
User avatar
Support
Site Admin
Posts: 1840
Joined: Sun Oct 02, 2011 10:49 am

How to use the datafile (database) object

Post by Support » Sun Oct 02, 2011 9:34 pm

Here is a working script showing how to use the DataFile object...

Code: Select all

WordList = 'Mike,Joe,Diane,Zack,Yany,Joe,Marie,David,Mike,Ken';
// Note that the above contain duplicates.

// Make all the words one per line...
WordList.Replace(',', crlf);

// Set our database file name and path...
DataFileName = ScriptPath + '$data.dat';

// Create our database object...
DF = New(DataFile);

// Open the database...
DF.Open(DataFileName);
// Make the database indexed in ascending order...
DF.SortedIndex;
// Empty the database...
DF.Truncate;

// Iterate through the all the words...
for each WordList as aWord do begin

	// If the word does not exist in the database...
	if DF.Find(aWord) < 1 then
	  // then add it...
		DF.Append(aWord);

end;

// Close the database...
DF.Close;

Output.Clear;

// Reopen the databse...
DF.Open(DataFileName);

// Output every sorted records...
for x = 1 to DF.Count do
	Output(DF.Read(x));

DF.Close;
Your support team.
http://SoftByteLabs.com

Post Reply