What's the Value of "FileName" in your Line 14?
Because right now i can't make heads or tails from your code in Line 12 and Line 13
In Line 12, you construct your local var "FileName" from something called "C-BasePath" and "Bit2" (which you seem to use as a constant).
What's C_BasePath (Yes, i can guess what it is!)?
In the next Line you check a (boolean)-Variable from somewhere, and if True, you overwrite the Value in "FileName" with something called "LOC" and Bit2 again.
Heads or Tails;
Var
Line 6 Bit2 : String = 'BDX0.txt';
Line 9 ListBox5.ItemIndex := 0; <-- Setting focus
Line 10 LevelUpperBoxes(0); <-- procedure which set focus on 9 other listboxes
Line 11 Bit1 := AFileName; <-- Contains AFILENAME (Passed to the Write proc
Line 12 FileName := C_BasePath + Bit2; <-- Explained below
Line 13 if OneDirectory then begin FileName := LOC + Bit2; end; <-- Explained below
Line 14 AssignFile(OutFile, FILENAME); <-- Explained below
I work with really large files, 8,9 and 11 million lines of Text files.
I keep all of these files on X:\FAAFiles\ . Which is declared:
Const C_BasePath = 'X:\FAAFiles\';
In FormCreate I do a LOC := Application.Location;
So the procedure is called:
SaveMstData('BDX0.txt');
Bit1 := 'BDX0.txt';
FileName := C_BasePath + Bit2; So FileName = 'X:\FAAFiles\BDX0.txt' <--Normal file path
I have a GLOBAL software switch called OneDirectory : Boolean = False;
if OneDirectory is set to false the FileName at Line 13 in the AssignFile(OutFile, FILENAME); will be 'X:\FAAFiles\BDX0.txt'.
if OneDirectory is set to True then the FILENAME at Line 13 in the AssignFile(OutFile, FILENAME) will be 'D:\CurrentProject\ BDX0.txt';
I have this in all my read and write procedures for two reasons.
I can set up test data, throw the switch to True and work with a different set of data. And I do this where my program executable is loaded.
If I'm asked to post a program, I can set the switch to True, zip the program and data and post. Whoever looks at it can build and run all in on directory. When there done delete the directory.
Hope this answer your questions.