From: eldorado@en.ecn.purdue.edu (Dave Jansen)
Newsgroups: comp.sys.hp48
Subject: copy.move
Date: 13 Feb 92 23:57:18 GMT
Organization: Purdue University Engineering Computer Network

Today a COPY and a MOVE program for the HP28S.
COPY copies one or more objects from the current dir in another dir and
MOVE .... (difficult question,ehh?? ;-)
 
usage:
======
 
1: <global name>   or   <list of global names>
MOVE   or   COPY
<now change the directory>
CONT
 
 
e.g:
====
 
 
1: 'XYZ'
COPY
HOME
CONT
 
 
1: VARS
MOVE
UP
CONT

The syntax for the program RENAME is
 
2:   <old name>
1:   <new name>
 
RENAME will rename anything, the only stipulation is that you be present in
the directory in which the variable/directory you wish to rename resides.
 
The programs SAVE, LOAD, and DELETE use a subdirectory, located in HOME
directory, called RAM (or whatever you would like to call it :). 

RENAME not only renames a variable/directory but it also preserves the
current directory order.  You will find that depending upon the size of the
directory in which you are in, and the location of what you wish to rename
and the size of the directory of which you wish to rename, that it can
take a considerable amount of time to execute.  (Other factors may apply, like
how much memory is left and whether you have sped up the speed of the
calculator.)
 
 
+------------------------------------------------------------------+
! true name: Ulli Horlacher *     e-mail: framstag@dtupev5a.bitnet !
! nick name: Framstag       *             s_horlac@dulruu51.bitnet !
!      or    Fraturday      *             50177::s_horlacher       !
!                           * snail-mail: Ulli Horlacher           !
!                           *             Landfriedbuehl 5         !
! Universitaet Ulm          *             D-7900 Ulm               !
! West-Germany              *             West-Germany             !
!******************************************************************!
!                 "Murphy was an optimist"                         !
+------------------------------------------------------------------+

Cut Here 8<-------------------------------------------------------------
%%HP: T(3)A(D)F(.);
DIR
COPY
\<< 8 CF \->CM \>>

MOVE
\<< 8 SF \->CM \>>

\->CM
\<< \->O\->L                 @ make a list
   1 ol SIZE FOR             @ loop from 1 to # of objects
     i ol i GET              @ get object name
     DUP RCL                 @ and contence
     OVER                    @ object name
     IF 8 FS? THEN PURGE     @ MOVE? then delete object in the source dir
     ELSE DROP END           @ else drop name of object
     SWAP NEXT               @ end of loop
   1 ol SIZE                 @ from 1 to # of objects
   'ol' PURGE                @ delete no more longer needed object-list
   HALT                      @ now change the dir
   START STO NEXT            @ store all objects in the stack
\>>
 
\->O\->L
\<< DUP IF TYPE 5 \=/        @ is it not a list? (only one object)
   THEN 1 \->LIST END        @ then make a list
   'ol' STO                  @ store it
\>>

RENAME
\<< SWAP DUP                                     @ check to see if it is a
   IFERR RCL                                     @ dir or variable.
   THEN DROP SWAP \-> o n                        @
    \<< PATH o EVAL VARS DUP SAVE SWAP           @ routine for renaming a dir
       DUP \->DIR o EVAL CLUSR DUP HOME          @
       \->DIR VARS o PURGE n CRDIR DUP o         @
       POS 1 - 1 SWAP SUB n + ORDER n            @
       EVAL SWAP DUP LOAD DELETE \->DIR \>>      @
    ELSE                                         @
     VARS 3 PICK PURGE SWAP 4 PICK STO DUP       @ routine for renaming a
     3 ROLL POS 1 - 1 SWAP SUB SWAP + ORDER      @ variable
    END                                          @
\>>                                              @

SAVE
\<< IF DUP { } SAME NOT THEN                     @ takes either a name or a
    IFERR LIST\-> THEN                           @ list of names and copies
     1                                           @ then from the current dir
    END                                          @ to the RAM dir
    1 START PATH SWAP DUP RCL                    @
    RAM SWAP STO \->DIR -1 STEP                  @
   ELSE                                          @
    DROP                                         @
   END                                           @
\>>                                              @

LOAD
\<< IF DUP { } SAME NOT THEN                     @ takes either a name or a
    IFERR LIST\-> THEN                           @ list of names and copies
     1                                           @ then from the RAM subdir
    END                                          @ to the current dir.
    1 START PATH RAM SWAP DUP RCL                @
    SWAP ROT \->DIR STO -1 STEP                  @
   ELSE                                          @
    DROP                                         @
   END                                           @
\>>                                              @

DELETE
\<< PATH RAM SWAP PURGE \->DIR \>>               @ erases files from RAM dir

\->DIR
\<< DUP SIZE 1 SWAP                              @ traverses down a dir path
   FOR x                                         @
    DUP x GET EVAL                               @
   NEXT                                          @
   DROP                                          @
\>>                                              @
END
-- 
I am a self-made man who worships his creator.
________________________________________________________________________________
David Jansen            |  INTERNET: eldorado@en.ecn.purdue.edu
Electrical Engineering  |  BITNET:   eldorado%ea.ecn.purdue.edu@purccvm

