home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crawly Crypt Collection 2
/
crawlyvol2.bin
/
utility
/
misc
/
master
/
batch
/
macros.bat
< prev
next >
Wrap
DOS Batch File
|
1990-03-25
|
6KB
|
197 lines
#--------- Initialisations for Master instead of a Save-File ------------------
# This batchfile includes some useful macros. It can be used as an
# initialisation file for Master or as an example for your own batchfiles.
# It is useful to have such a batchfile beside the normal Master-SAVE-file.
# A batchfile is easier to maintain and is a good reference when printed.
rem MASTER-Initialisation started
Unix; # because we use / as Directorydelimiter
alias setdir 'set \$1 \$2'; # local, allows arbitrary TABS in SET command
#-------------------------- status-variables -----------------------------------
rem status-variables
Alarm wait
noDelimiter
noDostrace
noEcho
Hold
Home /master
noNorec
Magic
Path /tools,/batch,$HOME
Prompt black \; rem \; datetime \; cd \=> cwd \; rem (\$cwd)
noQuiet
Sign_on ls
Sort time
noTalk
Unix 6; # * as searchstring for all files, / in XARGS
noUserred
# Varsize 100000; # allow large pipes
Virgin 12; # no Master-wildcards in programs, keyboard redefinable
Wrap
Xargs 14; # Atari standard ARGV & xArg, filehandle 2 = CON:
#------------------------ control structures -----------------------------------
rem control structures
# nextitem list variable - takes the next value out of the list
alias nextitem 'car \$1 => \$2; cdr \$1 => \$1'
# increment variable - increments the numerical value of variable by 1
# decrement variable - decrements the numerical value of variable by 1
alias increment 'eval \$1 1 + => \$1'
alias decrement 'eval \$1 1 - => \$1'
# this little trick allows you to get the list of all active drives
alias alldrives '{lock => locked; lock A B C D E F G H I J K L M N O P; lock; unlock -o; lock \$locked -> locked;}'
# the following 3 macros are short forms of some often used tests
# Usage: 'ifxyz variable { ...'
alias ifglobal if not exec "set? -g \$1" \$+
alias iflocal if not exec "set? -l \$1" \$+
alias ifempty if exec "{car \$1 => tmp; if tmp = '' {err 1;}}" \$+
# Not all possible loop constructs are realized in Master. But they can be
# programmed as alias. The following examples prove this.
# repeat
# statements
# until test
alias repeat 'loop {'
alias until 'if \$* {break;}}'
# foreach variable in list do
# statements with variable as 'loopcounter'
# endfor
alias foreach 'loop { ifempty \$3 {break;} nextitem \$3 \$1;:'
alias endfor }
# Other control structures like this case in the form of C are possible.
# switch variable
# case test value {
# statements
# [ endcase ]
# }
# ...
# endswitch
# test can be almost every usual if test:
# case == var
# case <> var
# case != var
# case in var
# ...
# (but not: `eof file' or `exists file')
alias switch '{ set switchvar \$1; set switching yes'
alias endswitch }
alias case 'if switching == "yes" && \$switchvar \$1 "\$2" \$+'
alias endcase set switching no
#------------------ links for toplevel directories -----------------------------
kbd nobell ;# no beep at the end of the toplink batch
if "$1" != "" {
# get our starting directory
set xx $@
setenv WORDENTITY /
set xx $xx[,-2]
unsetenv WORDENTITY
# toplink should be in the same directory
$xx/toplink.bat
unset xx
}
kbd bell
#-------------------- short forms for Directories ------------------------------
setdir tdir /tools
#------------------------- other aliases ---------------------------------------
rem other aliases
# for programs without ARGV or xArgs
alias expand '{set x \$*; cdr x => x; files -k200 \$x => x; \$1 \$x;}'
# if Master is several times in memory, this can be useful
alias toplevel Alias bye rem TOPLEVEL
alias save 'unalias bye; Save'
# It is useful to include a line like 'cd $workdir' in STARTUP.BAT, so that
# this alias allows you to continue with your work where you have finished.
alias worksave 'cd => workdir; save'
# The following 3 shortcuts are easier to type
alias ++ pushd
alias -- popd
# To clear the whole stack (note the tail-recursion)
alias --- 'if not exec "popd" {---;}'
# For absolute unix-freaks. The comment lets you use this only for showing all
# environment vars and not as an alias for setenv.
alias @ 'setenv;:'
# Dangerous commands should ask the user before they do something irreversible
alias rm Rm -i
alias touch Touch -i
# Send output to the printer
alias lpr 'cat >prn:'
alias ll Ll -u
alias ls Ls -un
alias l ls
alias h history -t
# Who always has the clock set correctly wants to know when a file was created
# not whn it was last copied.
alias cp Cp -t
alias mv Mv -t
alias pack Pack -t
alias unpack Unpack -t
# The following alias is used in the PROMPT-string
alias datetime '{date => x;time => y;show -m => z;printf "%s, %s\\t\\t%s" x y "$z[6]";}'
# A simple screen saver for monochrome display
alias wait 'inverse; cls; get => x; normal; cls'
# With the next alias in the prompt it's easier to use the previous one as
# alarm to turn the monitor dark after some time.
alias black 'if ALARMTIME != "" { chrono \$ALARMTIME > NUL:; }'
set ALARMTIME 00:05:00
# If you want to execute a program in a special directory (because you don't
# use symbolic links) the following macro helps. After the work is done it
# goes back to the current directory.
# Usage: 'do directory command parameters'
alias do 'pushd \$1; \$+; popd'
# With status variables it's a little bit tricky to save and restore the old
# state. The following macro does the job. Note the semicolons before '}'. They
# are absolutely necessary.
# Usage: 'state statusvar variable'
alias state 'cdr -0g \$1 => \$2; ifempty \$1 {set \$2 1; } else {eval \${\$2} => \$2; }'
# And this is a first application of state. The program runs in Virgin-Mode
# (perhaps needed if you want to run a program that permanently changes the
# gemdos or bios-traps, normally these are restored by Master).
# Usage: 'virdo program params'
alias virdo '{state VIRGIN old; virgin; \$*; virgin \$old;}'
alias mouse ~tdir/mouse.tos
key F10 save@
key F4 wait@
key +F9 mouse@
key F9 ~tdir/desk@
export ;# make SET-variables visible in the outer world
#-------------------------------------------------------------------------------
unalias setdir ;# we no longer need this
rem initialisation completed