• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Explore the powerful function SysMoveObject

Started by jep, 2008.06.02, 11:32:01

Previous topic - Next topic

jep

Marked as: Normal
Hello,

If you've used the command line and copy and/or move you know that they're quite restricted. While command "Copy" can copy files between drives, "Move" can only move them between folders on the same drive. Some may argue that it has been designed that way by intention, but we can still explore the power of rexx and rexxutil to create our own improved version.

The function SysMoveObject included in RexxUtil is quite powerful, yet easy to use, can handle not only files, but also folders, program objects etc. and it should therefore be quite easy to create a replacement command for Move.

The code below to parse command line parameters may not work very well in all cases, but I've tried to make it as robust as possible.

//Jan-Erik

/* Replacement command for Move, reloc.cmd */

IF ARG() = 0 THEN
        Return Usage()

CALL RxFuncAdd 'SysMoveObject', 'RexxUtil', 'SysMoveObject'
rc = 0
PARSE VALUE ARG(1) WITH from '"<'to'>"'
IF LENGTH( to ) = 0 THEN
DO i = 1 TO WORDS( from )
  temp = SUBWORD( from, 1, i )
  IF STREAM( temp, 'C', 'QUERY EXIST' ) <> '' THEN
  DO
    rc = SysMoveObject( temp, SUBWORD( from, i + 1 ) )
    IF rc THEN
      SAY temp 'moved to' SUBWORD( from, i + 1 )
    ELSE
      SAY "Couldn't move" temp 'to' SUBWORD( from, i + 1 )
    Return rc
  END
END
ELSE to = '<'to'>'
rc = SysMoveObject( from, to )
IF \rc & i > WORDS( from ) THEN DO
  SAY "Couldn't find input file"
  Return -1
END
IF rc THEN
  SAY from 'moved to' to
ELSE
  SAY "Couldn't move" from 'to' to
Return rc

Usage:
SAY 'Usage:'
SAY 'RELOC obj tgt'
SAY
SAY 'RELOC C:\CONFIG.SYS H:\'
SAY 'RELOC "<WP_INTERNET>" "<WP_CONNECTIONS_FOLDER>"'
SAY 'RELOC C:\Temp "<WP_DESKTOP>"'
Return 0