Hi Staphanos,
Glad you got is sorted, those kind of bugs are really annoying, but also give great satisfaction when cracked.
A little tip, not just to you, but anyone else reading this. Seeing output when doing forms is difficult, apart from debugging, there is no simple way. In DOS, one can just use WriteLns (assume equivalent in unix). What I do when I need to see data when doing a form is a use a separate list, usually debug_list. Whenever I need to see anything, I add it to the list, which is basically just the equivalent of WriteLns.
// in either top level class or as a separate global var, so all of the program can see it
debug_list : TStringList; // zzz - if you look at my programs you will zzz a lot, it's an easy marker when add in test code or to do reminder
// Shift Control F is also very useful when doing a project as it searches all files (I usually just have set for open files)
// ...
debug_list := TStringList.Create;
// then whever I need to see something the program is doing, I add to debug_list
// say I have a method get_file_name which I have the string f, the filename,
// which is not doing what I expect
Function a_class.get_file_name( Const i : DWord ) : Boolean; // file op methods should be boolean, as numerous things can go wrong
// <some code in which f is assigned the filename>
debug_list.Add( 'In method: get_file_name, checking var f' ); // so when you look at the debug file you know what the following line refers to
debug_list.Add( 'i = ' + i.ToString + ', f = ' + f ); // Add only takes 1 string, so have to use + instead of ,
// and all parts must be strings, the .ToString is very useful, can be used as a very easy number to string converter anywhere (not purist tho)
debug_list.Add ( '' ); // just adds a blank line, us humans don't do well with solid blocks
//...
// now at the end of the program, just before the final close up
debug_list.SaveToFile( 'debug_file.txt' ); // use any extension for an easy modern text editor
// most modern text editors will take UTF8 or unicode, so non standard chars will show up
// if control chars, such as linefeed, were embedded they will show up, see demo below
FreeAndNil( debug_list ); // remember to free up, now have sent to file can close
This demo shows that a string with an embedded linefeed can be seen in the output file:
Procedure test_embed;
{
When this is run it can be seen that the file has a blank line after "A string", this would not be there without the added linefeed.
So this little demo illustrates that pascal, correctly, does not check the contents of the string, either when added to the list or
sent to the file.
These types of little demos are invaluable when you just want to check the way a command works.
}
Var
temp_list : TStringList;
s : String;
Begin
temp_list := TStringList.Create;
s := 'A string' + #13 + #10; // this is DOS & Windows end of line, unix as I understand it has just one char, but still the same
temp_list.Add( 'start line' );
temp_list.Add( s );
temp_list.Add( 'end line' );
temp_list.SaveToFile( 'demo.npp' ); // npp is just my extension for Notepad++, use txt for notepad or any other extension
// pascal adds end of line after each string, but as can be seen, does not check what it is in the string
FreeAndNil( temp_list );
End;
In my old age, my testing is often better than my actual code.
Phil