Hi folks
I have a short piece of code within a large program which is driving me mad!! It works fine if I run it as a stand alone bit of code but not when I have it within the program.
The object of the code is to set up some csv files with fixed data fields, the number and names of the files are "lap" plus the lap number. When I run as the separate little program, it correctly installs lap1, lap2 etc. but when I am running it within the main program, even though the inkeys pause shows the correct file name of lap1 having been strung together, it never opens a lap1 file. Frustratingly, if I set the loop to start at 0 it will open a lap 0, then skip lap1 and go to lap 2 - all subsequent lap files open just fine.
I can't see where it's going wrong. Why should it skip file 1 in the main program?
Ignore all the While inkey$="":wend bits - I just put those in so I could see the variables and file names.
Here are the code snippets - the first is the stand-alone version, modified slightly as it's not using a file name string or looking up in a separate random access file:
lapfile$ = "c:\race\rrclaps\test2\" + "lap" + x$ + ".csv"
filenum% = 10 + x%
WRITE #filenum%
, _TRIM$(STR$(y%
)), "00:00:00.000", "00:00:00.000", "00:00:00.000"
This is the same code but within the main program, fil$ being the current file name and laps% being the number of laps to be run. File 5 stores a list of race numbers, test2 is the filename for testing, so it's hard-coded into the short program for clarity, but uses fhe fil$ name to point to the right folder in the main program:
lapfile$ = "c:\race\rrclaps\" + fil$ + "\" + "lap" + x$ + ".csv"
filenum% = 10 + x%
WRITE #filenum%
, _TRIM$(num$
(1)), "00:00:00.000", "00:00:00.000", "00:00:00.000"
Anyone got any thoughts?