I debated somewhat before writing this posting whether I should post the whole situation lest you think I'm even stranger than you probably already think I am :), but I finally decided on reporting the whole story so you have the full context of what I am trying to accomplish.
You see, I'm writing a batch file that accepts its input from standard input (via "%@SafeExp[@Line[CON,0]]", to be exact), and if the input is from an actual file (rather than STDIN, which is unlikely, or a pipe, which is highly likely) I'd like the batch file to display a "percent done" figure when the right-shift key (just an arbitrary "choice") is depressed ala:
I'll note that the reason I want to do this is because this particular .btm "program" can take 10 to 15 minutes to run, and I'd like to be able to easily "query" its "current progress" (as a percent-done figure) whenever I want to.
So, if standard input is from other than the console (the value of "%_STDIN" being zero which should virtually always be the case given what this batch file is intended to be used for) I would like to be able to find the name of the input file (if the input is coming from a file rather than a pipe) so that I can then use the "@Lines" function to return the number of lines in the file and then calculate and display the percent done. (I'd also like to do the same thing if the input is coming from a pipe, but I find that unlikely.) So, when I execute the "history" command from the command line, I get "PercentCommand <AnInputTestFile.txt randomparm asampleparm etc" as the second to last line of the "history" list (the last line being "history | list", of course) which is exactly what I would want because I could then "parse out" the input file name. However, if I execute the "history" command from within the batch file, the command line that invoked the batch file is displayed except for the fact all indications of the input redirection are gone; i.e., "Echo %@ExecStr[-1,History]" produces just "PercentCommand randomparm asampleparm", all indications of the input redirection being gone. And the same thing is true if I use "@ExecArray". (I must admit that I do find the fact that the history command returns somewhat different results when run from an "@Exec..." function in a batch file than when run directly from the command line to be a little bit strange, but that's not really important.) And I will add here that the "%CmdLine" "variable" returns exactly the same results as the the "@Exec...[History]" functions, which I really didn't find all that surprising but was the reason I was trying to use the "History" command in an "@Exec..." function in the first place.
So the question is ultimately pretty simple: Is there a way I can accomplish what I am trying to accomplish and, if so, exactly how do I do that?
- Dan
You see, I'm writing a batch file that accepts its input from standard input (via "%@SafeExp[@Line[CON,0]]", to be exact), and if the input is from an actual file (rather than STDIN, which is unlikely, or a pipe, which is highly likely) I'd like the batch file to display a "percent done" figure when the right-shift key (just an arbitrary "choice") is depressed ala:
Code:
Iff %_RShift == 1 Then
Iff "%ShiftStatus" == "" Then
@Echo %ProgressIndication
Set ShiftStatus=1
EndIff
Else
Set ShiftStatus=
EndIff
So, if standard input is from other than the console (the value of "%_STDIN" being zero which should virtually always be the case given what this batch file is intended to be used for) I would like to be able to find the name of the input file (if the input is coming from a file rather than a pipe) so that I can then use the "@Lines" function to return the number of lines in the file and then calculate and display the percent done. (I'd also like to do the same thing if the input is coming from a pipe, but I find that unlikely.) So, when I execute the "history" command from the command line, I get "PercentCommand <AnInputTestFile.txt randomparm asampleparm etc" as the second to last line of the "history" list (the last line being "history | list", of course) which is exactly what I would want because I could then "parse out" the input file name. However, if I execute the "history" command from within the batch file, the command line that invoked the batch file is displayed except for the fact all indications of the input redirection are gone; i.e., "Echo %@ExecStr[-1,History]" produces just "PercentCommand randomparm asampleparm", all indications of the input redirection being gone. And the same thing is true if I use "@ExecArray". (I must admit that I do find the fact that the history command returns somewhat different results when run from an "@Exec..." function in a batch file than when run directly from the command line to be a little bit strange, but that's not really important.) And I will add here that the "%CmdLine" "variable" returns exactly the same results as the the "@Exec...[History]" functions, which I really didn't find all that surprising but was the reason I was trying to use the "History" command in an "@Exec..." function in the first place.
So the question is ultimately pretty simple: Is there a way I can accomplish what I am trying to accomplish and, if so, exactly how do I do that?
- Dan