• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Simple program - how would you do this?

Muse

Lifer
It's for myself, but it would be cool if I could provide the solution to others in the support thread at AVS for the HDTV card I'm using, the MIT MyHD 130. Here's the problem:

When time shifting, the program creates files every 20 seconds. The first is named timeshift(1)tp, the 2nd is timeshift(2).tp, the 4012th is timeshift(4012).tp, IOW the nth is timeshift(n)tp. The problem is that the program looks for the highest n before creating the next file and I'm told it uses floats and when n is high enough a small dropout occurs from that point forward. So, when you view the video after n is sufficiently high (depending on the power of the CPU used), the dropouts occur (they are in the actual recording). My programming solution here is to change the names after a certain point. I can shut down the program momentarily after watching the first 5 hours (for example), which would put the highest n at 900. I run my little program and it deletes the first 900 files and renames the rest, giving them all a new n, call it m, where m=n-900. Then I restart the program, and timeshifting resumes, and I've only lost a few seconds, the time it took to shut down the program and run the utility.

I know I can do it in FoxPro, but AFAIK I couldn't give it to someone without the distribution package. IOW, FoxPro executables need the runtime. It's going to take me a little while to work up the chops in FoxPro and test it, but I can do it.

What program would you use to do this and could it run without a runtime so that it could be distributed?
 
Last edited:
1. Report that awful code to the manufacturer.

2. Whenever I need to do something nefarious like this (on Windows), I usually resort to AutoHotKey. On Linux, python.
 
So it sounds mostly like bunch of file operations are needed? Sounds like a job for a scripting language.

I agree with degibson, see if the manufacturer will update.
 
Can the program accept a file name instead of the standard timeshift.
Does the program have to be restarted to get the file name.

If you have to brute force; have a script of some type follow the program and do renaming of each files when created and closed.
that way; you only have to shut down the program long enough to restart it after clearing the last file name. Less than 1 second lost.
 
Can the program accept a file name instead of the standard timeshift.
Does the program have to be restarted to get the file name.

If you have to brute force; have a script of some type follow the program and do renaming of each files when created and closed.
that way; you only have to shut down the program long enough to restart it after clearing the last file name. Less than 1 second lost.
I don't think the program will deal with a filename other than timeshift(n).tp when timeshifting.

Yes, the manufacturer should fix it but I think they aren't particularly into supporting it any more. I don't know that they are going to release any more versions of the application. And I doubt that the HDTV card is still being manufactured, although I'm sure they are still for sale new, just very discounted from what they used to sell for (around 25% of what it used to sell for).

I can do it in FoxPro easily. I was just hoping I could create a little program I could distribute to people who have the card who follow the thread at AVS Forums. I could upload the file, but the FoxPro runtime is another matter. In FoxPro I'm just going to pass a parameter, being the lowest N I want to keep, say 568. So timeshift(568).tp would be renamed timeshift(1).tp, timeshift(569).tp would become timeshift(2)tp, etc. I'll drop the program in the timeshift buffer folder and run it there.
 
Last edited:
Here's the FoxPro program I wrote to do this. It's untested. You better believe I'm going to test this before turning it loose on my live data!

PROCEDURE myhd_ts
PARAMETERS tnEnd, tnChop, tnStart
PRIVATE lcFilename, lcNewName
lcFilename=''
IF alert("Have you closed MyHD?","No;Yes")=1
RETURN
ENDIF
IF TYPE('tnStart')=.L.
tnStart=1
ENDIF
IF TYPE('tnEnd')=.L.
=alert("First parameter designates the LAST timeshift file in the buffer.")
RETURN
ENDIF
IF TYPE('tnChop')=.L.
=alert("Second parameter represents the FIRST timeshift file to keep. The 3rd, if specified, is the first timeshift file in the buffer. If not passed, it's assumed to be timeshift(1).tp.")
RETURN
ENDIF
FOR i=tnStart+tnChop TO tnEnd
lcFilename = 'timeshift(' +ALLTRIM(STR(i)+').tp')
lcNewName = 'timeshift(' +ALLTRIM(STR(i-tnChop)+').tp')
RENAME FILE (lcFilename) TO (lcNewName)
ENDFOR
=alert("The adjustment is complete. You can restart MyHD.")
RETURN
 
2. Whenever I need to do something nefarious like this (on Windows), I usually resort to AutoHotKey. On Linux, python.

This. You can implement your FoxPro program, without a runtime, and with a distributable windows binary, in about as many lines, in AutoHotKey.
 
This. You can implement your FoxPro program, without a runtime, and with a distributable windows binary, in about as many lines, in AutoHotKey.

Using the FoxPro program?

I tested, debugged and fixed the program. This works:

PROCEDURE myhd_ts
PARAMETERS tnEnd, tnChop
PRIVATE lcFilename, lcNewName
SET DEFAULT TO GETDIR()
lcFilename=''
IF alert("Have you closed MyHD?","No;Yes")=1
RETURN
ENDIF
IF TYPE('tnEnd')='L'
=alert("First parameter designates the LAST timeshift file in the buffer.")
RETURN
ENDIF
IF TYPE('tnChop')='L'
=alert("Second parameter represents the FIRST timeshift file to ;
keep.")
RETURN
ENDIF
FOR i = tnChop TO tnEnd
lcFilename = 'timeshift(' +ALLTRIM(STR(i)+').tp')
lcNewName = 'timeshift(' +ALLTRIM(STR(i-tnChop)+').tp')
RENAME (lcFilename) TO (lcNewName)
ENDFOR
=alert("The adjustment is complete. You can restart MyHD.")
RETURN


According to FoxPro help, the directory where the files reside need to be in the FoxPro path. So, I adjusted the FoxPro environment to have the MyHD data directory in the FoxPro path. Before running the program I need to delete the first N files in the directory, then call the function with 2 parameters. If I delete 568 files and the last file is timeshift(1792).tp, the call is:

DO MyHD_ts WITH 1792, 568

I could have designed the program so it doesn't need parameters, because those are implicit in the file names. I'd have to use the ADIR() FoxPro function. Maybe I will, but this works.
 
Last edited:
Back
Top