[Coco] quick basic09 copy program

Willard Goosey goosey at virgo.sdc.org
Wed Jan 30 06:53:50 EST 2008


Quicky program to copy all files from the current data directory to
/dd/foo. Hack on it as you wish.

I'd like to say I just threw this together, but BASIC-09 is subtle and
quick to anger. ;-) Actually, this did teach me a couple of things
about BASIC09.

But it's still pretty much quick and dirty. Not very efficient, as it
forks a shell for every file it copies.


PROCEDURE wcopy
(* copy all files from cwd to another dir
DIM cwd:BYTE
DIM origin,fc:STRING[32]
DIM dest:STRING[128]

OPEN #cwd,".":READ+DIR
WHILE NOT(EOF(#cwd)) DO
GET #cwd,origin
RUN entry2name(origin)
fc=LEFT$(origin,1)
IF fc<>CHR$(0) AND fc<>"." THEN
dest=" /dd/foo/"+origin
SHELL "copy "+origin+dest
ENDIF
ENDWHILE
CLOSE #cwd
END

PROCEDURE entry2name
PARAM entry:STRING
(*arguement: a OS-9 directory entry: 32 bytes long, 29 byte max. filename
(*3 byte LSN, filename's last character has 8th bit set
(*
(*output: The filename, with the last character's 8th bit cleared
(*If you have a dir. entry that doesn't have the 8th bit set on the
(*last character, OS-9 crashed when you read the directory...

(*Willard Goosey
(*goosey at sdc.org

DIM i,tv:INTEGER
DIM fname,lc:STRING

i=1
LOOP
tv=ASC(MID$(entry,i,1))
EXITIF tv>127 THEN
fname=MID$(entry,1,i-1)
lc=CHR$(tv-128)
fname=fname+lc
ENDEXIT
i=i+1
ENDLOOP
entry=fname
END


--
Willard Goosey goosey at sdc.org
Socorro, New Mexico, USA
"I've never been to Contempt! Isn't that somewhere in New Mexico?"
--- Yacko



More information about the Coco mailing list