PreviousNextIndex

OS-RENAME statement

Executes an operating system file rename or directory rename command from within ABL.

Syntax

OS-RENAME 
  { source-filename | VALUE ( expression ) } 
  { target-filename | VALUE ( expression ) } 

source-filename
VALUE ( expression )
target-filename
VALUE ( expression )
Example

This procedure opens a dialog box that prompts the user to choose a file to rename. It then prompts for a new name. Finally, the procedure uses the OS-RENAME statement to rename the file.

r-os-nam.p
DEFINE VARIABLE sourcefile AS CHARACTER NO-UNDO. 
DEFINE VARIABLE targetfile AS CHARACTER NO-UNDO FORMAT "x(20)"  
  VIEW-AS FILL-IN. 
DEFINE VARIABLE OKpressed  AS LOGICAL   NO-UNDO INITIAL TRUE. 
Main: 
REPEAT: 
  SYSTEM-DIALOG GET-FILE sourcefile 
    TITLE "Choose a File or Directory to Rename" 
    MUST-EXIST 
    USE-FILENAME 
    UPDATE OKpressed. 
  IF OKpressed = FALSE THEN 
    LEAVE Main. 
  UPDATE targetfile WITH FRAME newnameframe. 
  OS-RENAME VALUE(sourcefile) VALUE(targetfile). 
END. 

Notes
See also

OS-ERROR function


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex