KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Error -48 when Moving a Document using the MOVE DOCUMENT Command
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: June 15, 2001

If you are attempting to move a document using the MOVE DOCUMENT command and are getting an error -48, it should be for the following reason: although it is not mentioned in the documentation, you need to delete existing documents that are located in the target folder and have the same name as the one you are copying. This can be done using the DELETE DOCUMENT command.

The following code lets you choose a document, moves it to the location you select and also manages potential conflicts between filenames (for both Mac OS and Windows).

`Main method

ALERT("Please select document to move!")
$docRef:=Open document("")
CLOSE DOCUMENT($docRef)
$DocName:=Retrieve_docname (document)
$MyDoc:=document
$Path:=Select folder("Please select target folder !")
$TargetDoc:=$Path+$DocName
$CheckPath:=Test path name($TargetDoc)
Case of
  : ($CheckPath=1)
   CONFIRM("That file already exists, do you still want to proceed?")
   If (OK=1)
    DELETE DOCUMENT($targetdoc)
    MOVE DOCUMENT($MyDoc;$targetdoc)
  Else
    ALERT("Move canceled!")
  End if
  : ($CheckPath=0)
  CONFIRM("That file name is used by a folder, do you still want to proceed?")
  If (OK=1)
    DELETE FOLDER($targetdoc)
      `it will delete it only if there are no file in that folder
    MOVE DOCUMENT($MyDoc;$targetdoc)
  Else
    ALERT("Move canceled")
  End if
  : ($CheckPath<0)
  MOVE DOCUMENT($MyDoc;$targetdoc)
End case
In this code a subroutine is used (Retrieve_Docname) to isolate the actual name of the document. It uses the following code.`Retrieve_Docname subroutine
$ShortenedVal:=$1
PLATFORM PROPERTIES($Processor;$DoNotCare;$DoNotCare2)
If ($processor=2)
  $separator:=":"
Else
  $separator:="\"

End if

$Pos:=Position($separator;$ShortenedVal)
Repeat
  $Pos:=Position($separator;$ShortenedVal)
  $ShortenedVal:=Substring($ShortenedVal;$Pos+1)
Until (Position($separator;$ShortenedVal)=0)
$0:=$ShortenedVal