I need some advice from the Kixtart sages.
I am writting a script that does some automated backups to CD and in the course of doing so, I write a log file that looks like this:
Code:
******************************************************************
Results of Backup_for_IDubbelboer_on_January_15_2006
******************************************************************
The backup of files took 0:03:31 to complete.
The following files, if any, were skipped as they were in use.
The compression and encryption of the backup file took 0:19:21 to complete.
The splitting of the compressed backup file took 0:02:26 to complete.
The file was split into 2 parts.
It took 0:03:00 to burn the 2 CD(s).
CD 1 took 0:00:40 to burn.
CD 2 took 0:02:20 to burn.
Backup completed successfully on 2006/01/15
Now I have to read data out of this file at a later date and on a different computer, so I have some code that looks like this:
Code:
$ = OPEN(1,"c:\backup\backup.log",2)
DO
$DoExit = @ERROR
$LogRead = READLINE(1)
SELECT
CASE (NOT INSTR($LogRead, " on ") = 0) AND (NOT $OSInfo[1] = 2)
$BackupDate = SUBSTR($LogRead, 34, 10)
CASE (NOT INSTR($LogRead, " bytes") = 0)
$BackupSpace = SUBSTR($LogRead, 1, (INSTR($LogRead, " bytes") - 1))
$BackupTime = SUBSTR($LogRead, (LEN($LogRead) - 20), 8)
CASE (NOT INSTR($LogRead, "e backup file t") = 0)
$CompEncryptTime = SUBSTR($LogRead, 55, 8)
CASE (NOT INSTR($LogRead, "d backup file t") = 0)
$SplitTime = SUBSTR($LogRead, 49, 8)
CASE (NOT INSTR($LogRead, "t took") = 0)
$CDBurnTime = SUBSTR($LogRead, 8, 8)
$CDBurnCount = SUBSTR($LogRead, 29, 1)
CASE 1
ENDSELECT
This code works great, but now I have to be able to support both French and English log files.
With my current technique, I am forced to write another case statement with the correct values to read from a French text file. I also have to write code to make sure I detect the language of the text file before I read it.
So does anyone have a better way of handling this?
Keeping in mind these requirements:
1. Output has to be written to and read from a unicode text file. (If you don't know how to work with unicode, don't worry I can adjust an ascii solution.)
2. Has to be user friendly as non techies will be reading the file as well.
Anyone worked through this kind of problem before?