Thread View: comp.soft-sys.matlab
1 messages
1 total messages
Started by Michael Maurer
Sat, 23 Jan 1993 01:08
SOURCE: tempname.m - generate temporary filename
Author: Michael Maurer
Date: Sat, 23 Jan 1993 01:08
Date: Sat, 23 Jan 1993 01:08
67 lines
2246 bytes
2246 bytes
Hoping to start a trend, here is an unsolicited matlab m-file.
TEMPNAME generates a temporary filename.
Suggested improvements are welcome.
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# tempname.m
# This archive created: Fri Jan 22 16:55:48 1993
export PATH; PATH=/bin:$PATH
echo shar: extracting "'tempname.m'" '(705 characters)'
if test -f 'tempname.m'
then
echo shar: will not over-write existing file "'tempname.m'"
else
sed 's/^XX//' << \SHAR_EOF > 'tempname.m'
XXfunction s=tempname(prefix,ext,touch)
XX
XX%TEMPNAME
XX% S=TEMPNAME returns a temporary filename.
XX% S=TEMPNAME(PREFIX) returns a filename with PREFIX prepended.
XX% S=TEMPNAME(PREFIX,EXT) appends EXT.
XX
XX% Michael Maurer, Feb 4 1991
XX% Copyright (c) 1993 by Michael Maurer
XX
XXif (nargin<1)
XX prefix='tmp';
XXend
XXif (nargin<2)
XX ext='';
XXend
XXif nargin<3,
XX touch=1;
XXend
XX
XXt = clock;
XXt(6) = t(6)*100;
XXt=fix(t);
XXts=sprintf('%02.0f%02.0f%04.0f',t(4),t(5),t(6));
XXs = [prefix ts ext];
XX
XX% Now add distinguishing letter if necessary
XXlet='a';
XXwhile exist(s)==2 & let<='z',
XX s=[prefix ts let ext];
XX let=setstr(let+1)
XXend
XXif exist(s)==2,
XX error('Failed to find temporary filename')
XXend
XXif touch,
XX eval(['!touch ' s])
XXend
SHAR_EOF
if test 705 -ne "`wc -c < 'tempname.m'`"
then
echo shar: error transmitting "'tempname.m'" '(should have been 705 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
--
______________________________________________________________________
Michael Maurer maurer@nova.stanford.edu (415) 723-1024
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads