1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sample 4START.BTM and 4EXIT.BTM files

Discussion in 'T&T - Scripting' started by nchernoff, Jun 9, 2008.

  1. nchernoff

    nchernoff Administrator
    Staff Member

    May 16, 2008
    Likes Received:
    Migrated From JP Software Wiki

    Sample 4START

    This 4START file demonstrates setting a colorful prompt using ANSI escape sequences and conditionally restoring the previous environment. It will also rebuild the JPSTREE.IDX file if this is the first time 4NT has been launched today.

    if %_pipe != 0 .or. %_transient != 0 quit
    alias /r c:\jpsoft\aliases
    color bri yellow on black
    iff "%@filedate[c:\jpstree.idx]" != "%_date" then
        echo Indexing C: in the background.
        start /min /low /c cdd /u c:\
    set s=Y
    inkey /c /k"YN[Enter]" /w10 /x Restore Previous Environment? (Yn) %%s
    iff "%s" eq "Y" .OR. "%s" eq "@28" then
      for %%s in (@c:\JPSOFT\drives.dat) do cdd %%s
      set /r c:\JPSOFT\env.dat
      dirhistory /r c:\JPSOFT\dirhist.dat
      history /r c:\jpsoft\history.dat
    set TREEEXCLUDE=d:\;e:\;f:\;g:\;h:\;I:\;J:\;K:\;L:\;M:\;N:\;O:\;P:\;Q:\;R:\;S:\;T:\;U:\;V:\;W:\;X:\;Y:\;Z:\;\\*\*
    ::Make the title bar show the version and build number
    set TITLEPROMPT=%_cmdproc %_4ver (%_BUILD) in %%_cwd
    title %_cmdproc %_4ver (%_BUILD)
    rem prompt=`%@exec[@color 15 on %@if[%@remote[%_disk] eq 0,2,4]%+echos [%_cwd%]%+color 14 on 0]$s`
    prompt=`%=e[37;%@if[%@remote[%_disk] eq 0,42,41];1m[$P]%=e[33;40;1m$s` 
    unset s
    Sample 4EXIT

    To work around some tricky issues with closing, I aliased my EXIT command.

    alias EXIT=c:\jpsoft\_4EXIT.btm
    I chose not to use the 4EXIT.btm file directly. So, if a process is closed by clicking on the close button or by Windows shutting down, nothing extra gets done. If I type EXIT from a 4NT prompt however, I can choose whether or not to save my current environment.

    if %_transient != 0 quit
    msgbox yesno "Save" Save Drive and Environment Settings?
    if %_? != 10 *exit
    cdd /a > c:\jpsoft\drives.dat
    cd >> c:\jpsoft\drives.dat
    set > c:\jpsoft\env.dat
    dirhistory > c:\jpsoft\dirhist.dat
    history > c:\jpsoft\history.dat
    Additional Information

    See the article on saving and restoring the environment for additional info: Save restore

Share This Page