I have a TStringgrid which I fill with predfined characters coming from some textfile. I also have the ability to save the contents to a textfile. The TStringgrid is 20 cols and 20 rows and each cell contains but one character ranging from A to Z. The textfiles are 400 bytes of size hence, they hold the 400 characters of my TStringgrid.
Now the hard part: I have as much as 18 different textfiles each filled with 400 characters. Now in all of those textfiles some words are hidden, (ref. wordsearching), those words are 5 characters long and are hidden twice in each file. The locations differ per file.
Example: in file oefen1.txt the word SPOKS is hidden twice. When this particular file is loaded, my stringgrid should monitor the cells in which the characters are places which form the word SPOKS. The first instance of this word covers the following cells of the TStringgrid: 4,3 - 5,3 - 6,3 - 7,3 - 8,3 (the first number being the column the second being the row > this instance is horizontally read from left to right)
Now I managed to grab hold of the cells by means of popping up a message in case one of the cells is clicked > here's my code:
procedure TForm1.SG1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
if (Acol = 4) and (Arow = 3) then
if (Acol = 5) and (Arow = 3) then
if (Acol = 6) and (Arow = 3) then
if (Acol = 7) and (Arow = 3) then
if (Acol = 8) and (Arow = 3) then
To monitor the second instance of that word as well would mean another 5 of those if (Acol = ..) and (Arow = ..) then ShowMessage('..') thingies.
Loading another textfile, would mean searching another word which covers different cells ofcourse. Given the 18 different textfiles, I'm now looking for some mechanism to let the name of the textfile loaded, determine which 10 cells to monitor.
Loading oefen1.txt would then automatically have the TStringgrid monitor the cells mentioned above, while loading oefen2.txt would then have the Tstringgrid monitor 10 other cells (which are covered by some other word)
How do I achieve that?
Should I store some info in the textfile which then functions like some ini file and determines which cells to monitor or should the loading set some variable or point to some procedure????????
Ps the person who manages to make this thingie work gets the points. Provide working samples and it would be great when you comment what it is you actually do.