copy a file using progress scripts

If I understand you correctly,

you want to write a progress code that will

1. copy a file (file type??) from some location
2. then, edit this file
3. finally move the edited file to some other location

is this correct ?
 
not fool-proof, but works okay ... you can add more error handling later...

Code:
[FONT=courier new]DEFINE VARIABLE iTemp        AS INTEGER NO-UNDO.
DEFINE VARIABLE cSrcFileName AS CHARACTER  NO-UNDO.
DEFINE VARIABLE cTrgFileName AS CHARACTER  NO-UNDO FORMAT "x(60)" VIEW-AS FILL-IN.
DEFINE VARIABLE OKpressed    AS LOGICAL NO-UNDO INITIAL TRUE. 

/*1. Copy File from Location-1 to Location-2 */

UPDATE cTrgFileName WITH FRAME copyframe. 

SYSTEM-DIALOG GET-FILE cSrcFileName 
       TITLE "Choose File to Copy" 
       MUST-EXIST 
       USE-FILENAME 
       UPDATE OKpressed. 

IF OKpressed = FALSE THEN RETURN NO-APPLY.
OS-COPY VALUE(cSrcFileName) VALUE(cTrgFileName).

/* 2. Edit the copied File */

RUN ShellExecuteA IN THIS-PROCEDURE 
     (0,
     "open",
     cTrgFileName,
     "",
     "",
     1,
     OUTPUT iTemp).
     
PROCEDURE ShellExecuteA EXTERNAL "shell32" :
     define input parameter hwnd as long.
     define input parameter lpOperation as char.
     define input parameter lpFile as char.
     define input parameter lpParameters as char.
     define input parameter lpDirectory as char.
     define input parameter nShowCmd as long.
     define return parameter hInstance as long.
END PROCEDURE.

/*3. Move the copied file*/ 

ASSIGN cSrcFileName = cTrgFileName.
UPDATE cTrgFileName WITH FRAME copyframe. 

OS-COMMAND SILENT MOVE VALUE(cSrcFileName) VALUE (cTrgFileName).

[/FONT]
 
Thanks for the script.
how can I make the changes without a window.....something like replace.
My file contents are "01" "Claims" 22/07/11 22/07/11 "EUR" "14"
I just want to change the date in this file to 23/07/11
 
Thanks for the script.
how can I make the changes without a window.....something like replace.
My file contents are "01" "Claims" 22/07/11 22/07/11 "EUR" "14"
I just want to change the date in this file to 23/07/11

You didn't understand the example on rosettacode.org?
 
I tried the rosettacode I got an error saying could not understand COPY-LOB Then I tried OS-COPY but it didnt replace.

Here is what I tried

DEF VAR i_cfile_list AS CHAR.
DEF VAR i_cfile_list1 AS CHAR.
DEF VAR i_cfrom AS char.
DEF VAR i_cto AS char.
DEF VAR ii AS INT.
DEF VAR lcfile AS CHAR.
i_cfile_list = "C:\temp\spl48176.pkx".
i_cfile_list1 = "C:\temp\spl48177.pkx".
i_cfrom = '"01"'.
i_cto = '"02"'.
OS-COPY VALUE ( i_cfile_list ) value ( i_cfile_list1 ).
i_cfile_list1 = REPLACE( i_cfile_list1, i_cfrom, i_cto ).


Thanks,
 
Is there any way you can upgrade to 10.1 or even 10.2? Version 9.1 is now pretty much obsolete.
 
Back
Top