The program compiles without errors in an administrators cmd screen.
D:\FreeBASIC>fbc.exe -lang qb d:\subsdir\convert-subs.bas
D:\FreeBASIC>cd \subsdir
D:\subsdir>convert-subs.exe
D:\subsdir>
And as seen above runs without (visible) errors.
However, there is no file created (if output file does not exist) or updated (if output file exists).
If I uncomment the print regel2 statement for converted lines, all looks great.
What is wrong in the sourcecode below, or why isn't the new file created/updated?
Code: Select all
rem Program to convert 2 timeformats on some lines in text files
rem All timestamps should be 59 seconds less
rem example:
rem file_to_convert.org.txt file_to_convert.new.txt
rem 0001 1 0001 1
rem 0002 00:01:24,776 --> 00:01:26,176 0002 00:00:15,776 --> 00:00:17,176
rem 0003 Hello. 0003 Hello.
rem 0004 0004
rem 0005 2 0005 2
rem 0006 00:01:29,936 --> 00:01:33,877 0006 00:00:20,936 --> 00:00:24,877
rem 0007 Hello! 0007 Hello!
rem 0008 - Oh, hi. 0008 - Oh, hi.
rem 0009 0009
rem 0010 3 0010 3
rem 0011 00:01:34,337 --> 00:01:35,697 0011 00:00:25,337 --> 00:00:26,697
rem 0012 Nice wether. 0012 Nice wether.
rem
dim as string regel1, regel2, tijd, mins, secs
dim as integer mini, seci, newtijd
dim as long file_num1, file_num2
file_num1 = FreeFile()
file_num2 = FreeFile()
Open "d:\subsdir\file_to_convert.org.txt" For Input As #file_num1
Open "d:\subsdir\file_to_convert.new.txt" For Output As #file_num2
DO Until EOF(file_num1)
Line Input #file_num1, regel1
IF left$(regel1, 3) = "00:" THEN
tijd = mid$(regel1, 4, 5)
gosub converttijd
regel2 = "00:" + tijd + mid$(regel1, 9, 12)
tijd = mid$(regel1, 21, 5)
gosub converttijd
regel2 = regel2 + tijd + right$(regel1, 4)
rem print regel2
print #file_num2, regel2
ELSE
print #file_num2, regel1
END IF
Loop
close #file_num1, #file_num2
END
converttijd:
mini = val(left$(tijd, 2))
seci = val(right$(tijd, 2))
newtijd = (mini * 60) + seci - 59
mini = newtijd / 60
mins = mid$(str$(mini),2,2)
if len(mins) = 1 then
mins = "0" + mins
end if
seci = newtijd mod 60
secs = mid$(str$(seci),2,2)
if len(secs) = 1 then
secs = "0" + secs
end if
tijd = mins + ":" + secs
return