Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Issue with CD_ENTER Alias

You're welcome ... my pleasure. I'll keep going if I have any more ideas. :-)

I like the whole idea of an automatic BTM when a directory is visited. But so far I haven't thought of something for it to do.
 
Depending on where you put autoex.btm, it's might be executed during PIPE and TRANSIENT instances of TCC (which is probably not desired). I used the check %[_PIPE]%_TRANSIENT NE 00 to check that.

I put an autoex.btm in my normal startup directory. It runs twice during TCC's startup. I don't need to have one there, but I'm wondering if there's a way to suppress it during startup. Any ideas?
 
I have autoex.btm files in relatively few of my directories, but here are some of the uses I make of it.
  1. I have directories for each of the financial institutions that I deal with (banks, credit cards, investment companies). They have autoex.btm files that display a list of the most recent statements. That way, I quickly see which ones are missing and need to be downloaded from the company's website. The output also reminds me of special aliases, such as one for automatically opening the most recent statement in Adobe reader. I can double-click the name of any statement to select it and then click my toolbar RUN button to open it. The script also copies the full path to the clipboard, which is handy when I'm downloading a statement from the website.
  2. For the top-level financial directory, autoex.btm displays a list of all the subdirectories. I can double-click to select one and then click the toolbar "CD/UP" button to change to that directory.
  3. I have directories for each utility (gas, electricity, etc.). The autoex script lists the most recent statement and the name of the spreadsheet I use to keep track of usage. I can double-click the name to select it and then click my toolbar RUN button to execute it.
  4. Each organization for which I volunteer has a directory, and that directory contains subdirectories for various functions. The autoex script displays a list of those directories with their descriptions.
I don't have autoex.btm files in any of the directories accessed during startup, and I've never had a pipe or transient instance of TCC use those directories (but adding your suggested code seems like a good idea). I can't think of any reasonable way to suppress its operation during TCSTART.BTM. Oh, could one test based on %_batchname by adding if "%@name[%_batchname]" EQ "tcstart" quit 1.
 
Well, of course what I suggested won't work for detecting TCSTART since the batchfile running is cdtests.btm. The parameter %0 also does not work. I'm too tired now (it's almost 1 am) to think this through. Maybe tomorrow.
 
Before I could get to bed, I thought of the following.

Early in TCSTART.BTM, I do set tcstart=1. Then at the end I do set tcstart=0.

I added the line if "%tcstart" EQ "1" quit 1 to cdtests.btm, and that worked.
 
I don't think the directory changes happen in TCSTART. I think they're just normal start-up stuff. In CDTESTS.BTM I can see how long TCC has been running and not run AUTOEX.BTM if that's less than (say) 2 seconds. I have a couple of plugin ways to get TCC's running time very easily. But, if I had to, I could do it without plugins. That would involve using @WMI to get TCC's start time and the current time, both in the format YYYYMMDDHHMMSS.mmmmmm±ZZZ ... using @INSTR to get dates and times ... turning them into AGES (@MAKEAGE) ... and doing a little math.
 
I found that UNALIASing the CD_Enter alias at the beginning of my .btm, and then ALIASing the CD_Enter at the end of my .btm, solved alot of my problems.

Not sure if this would help your issues or not.
Code:
@echo off
:: Use with the CD_Enter alias
unalias CD_Enter
switch %1
  case E:\Utils
    cdd %1
    dir /[d-0]
  case E:\Documents
    set thedir=%@getdir[%1]
    iff exist %thedir THEN
      cdd %thedir
    else
      ::NEXT SENTENCE
    endiff
endswitch
alias CD_Enter=e:\utils\cd_enter.btm

Joe
 
I found that UNALIASing the CD_Enter alias at the beginning of my .btm, and then ALIASing the CD_Enter at the end of my .btm, solved alot of my problems.

Joe
Thanks, Joe. I like that idea. Since I'm doing things this way: cd_enter=call v:\cdtests.btm && call autoex.btm I can just set a flag at the start of autoex.btm and unset it at the end, and test for it in cdtests.btm.
 

Similar threads

Back
Top