I am running into a big issue with one of my apps developed with RB and hope to get some help on this…
(sorry for the lengthy intro)
The app (running from a Kingston USB drive) is about entering or uploading data that is saved in text files with the INI format.
At startup the app checks for the presence of a USB dongle. If the dongle is present the app goes into “upload mode” otherwise into “data entry mode”.
In upload mode the app presents a list of INI files found on the USB stick. The user can select one or multiple files and click on the upload button. The files are then uploaded to a server and moved into an archive folder on the same USB stick. A user will frequently delete all files in the archive folder to clean up the USB drive. The archive is an extra backup in case an upload went wrong (although the app does error checking and reports if an upload failed but this extra archive copy is just an extra backup).
In data entry mode the user will be presented with a screen to enter data and this data is then saved in a new INI file (in the root of the USB drive where the app resides). The app will save (with whatever data is already filled in the form) every minute (so each time overwriting the same INI file) to have already some data saved when power would drop or any other situation that causes the app to close. Every form gets a unique ID (entered by the user but this is a person ID that is unique and consists of 7 digits). The filename is the unique code plus a “.dat” extension. Inside the file we have data (INI format) and the code is also saved as a field inside the INI file.
At start of the app, a listbox is populated with data from all INI files present in the root folder of the USB drive. This box is hidden and only made visible in the upload mode (I could not do this and only load data into the listbox if the app already knows that it needs to go inti upload mode but this does not seem to be the problem).
The app is closed after the upload or after entering one form of data.
All works fine but now (after more than a year in use) we have the following problem. There is (like 1 out of ten) some INI files that have a filename that does not correspond with the data inside. Very strange because the filename is generated on the basis of the same ID variable as saved inside the file. Looking further into the problem it seems that the data inside (in one of the problematic files) corresponds to an INI file that was on the same stick one year (or so) ago. Note that at the time of saving the new data, the old data file (that corresponds to the content in the new file) was already move to the archive and even already deleted (although I could retrieve it with an undelete tool).
To understand / fix the issue I did a few things:
set the object in which the INI data is stored to nil after getting data from the file (although it seems that RB destroys the object anyway once the method is terminated). This did not resolve anything but that could be expected as the old data was in a deleted file anyway so it would not be read in any case…
I created a simple debug system: each time my app does something it is added as a line in an unvisible listbox. When the app is closed each line of this listbox is saved in a text log file. Works fine except in the situation we need it: when the saved INI file has the wrong (i.e. old) content the log file contains also data from an old INI file (also a deleted one) and some extra binary characters at the end but no info from the listbox.
I need some help on this even if it implies professional (paid) support…