Gernot,
Can you help with a bit of code, I am trying to get the time into one of my programs, the code below works first time but when you run the code again it has not updated, Could it be that the file once accessed by Glbasic it will not close the file or "let go of the file for other programs", and when the dos shell trys to access it again it can't get access, If I am correct, are there any ways around it?.
Thanks, Maxheadroom.
Code:
Loop: // start
Shellcmd (“cmd /c time /t > tim.txt†,true ,false, rv) // shell out and put time in tim.txt
Getfile “tim.txtâ€,0,time$ // open file and get the time
Print time$,100,100 // print time out on screen
showscreen
Goto loop // loop for ever
Ha!
Never thought of that! Really funny. I sat here, really stunned for a minute until it occoured to me what happened.
See, GLBasic uses an internal buffer for a file for read/write access. As long as you don't access another file, no disc-io is performed. That is a speed boost for usual tasks. Here, it's a problem.
I don't have a GLBasic here (Linux), but I guess this should work:
Loop: // start
SHELLCMD (“cmd /c time /t > tim.txt†,true ,false, rv) // shell out and put time in tim.txt
GETFILE "", 0, time$ // flush the "tim.txt" file buffer, reopen "" (does not exist)
GETFILE “tim.txtâ€,0,time$ // open file and get the time
PRINT time$,100,100 // print time out on screen
SHOWSCREEN
GOTO loop // loop for ever
time has been restored
Thanks all working! :D