• close file in REXX

    From Bryan Rubingh@1:109/347 to All on Tue Aug 1 17:00:00 2000
    I've written a REXX program which reads one file, changes a few lines as
    it reads and writes to a second file, doing the above one line at a
    time. When it reaches the end of the first file, I want to copy the
    second file (the one REXX created) to another location. I've tried just
    doing:
    copy file2 file3
    but I get an OS/2 error when running the program that file2 is in use.
    Is there any way in REXX to close the file so that the OS can copy it?

    Thanks,
    Bryan Rubingh


    ... Rube Ink - Custom Programming/Computer Solutions

    ___ Blue Wave/QWK v2.20

    --- Maximus/2 2.02
    * Origin: OS/2 Shareware BBS, telnet://bbs.os2bbs.com (1:109/347)
  • From Herbert Rosenau@2:2476/493 to Bryan Rubingh on Thu Aug 3 10:36:50 2000
    Am 02.08.00 00:00 schrieb Bryan Rubingh

    I've written a REXX program which reads one file, changes a few
    lines as it reads and writes to a second file, doing the above
    one line at a time. When it reaches the end of the first file, I
    want to copy the second file (the one REXX created) to another
    location. I've tried just doing: copy file2 file3 but I get an
    OS/2 error when running the program that file2 is in use. Is
    there any way in REXX to close the file so that the OS can copy
    it?

    f = 'c:\config.sys'

    rc = stream(f, 'C', OPEN READ)
    if rc <> 'READY:' then return 1
    do while lines(f) > 0
    zeile = linein(f)
    /* do anything with zeile */
    end
    rc = stream(f, "C", "CLOSE")

    --- Sqed/32 1.15/development 387:
    * Origin: Kann den DFUe Suende sein ?! (2:2476/493)
  • From Murray Lesser@1:106/2000 to Bryan Rubingh on Thu Aug 3 02:51:00 2000
    (Excerpts from a message dated 08-02-00, Bryan Rubingh to All)

    Hi Brian--

    I've written a REXX program which reads one file, changes a few
    >lines as it reads and writes to a second file, doing the above one
    >line at a time. When it reaches the end of the first file, I want
    >to copy the second file (the one REXX created) to another location.
    >I've tried just doing:
    >copy file2 file3
    >but I get an OS/2 error when running the program that file2 is in
    >use. Is there any way in REXX to close the file so that the OS can
    >copy it?

    You have some other error, if file2 is the newly-created file. There
    is no OS/2 restriction against copying an open file to another file.
    There _is_ a restriction against copying a file _to_ an open file.

    In any case, in answer to your query, use the stream function:

    Call STREAM file2, 'c', 'close' /* file2 is the "from" file */

    Next time, post your REXX queries in the OS2REXX echo. You have a possibility of finding more REXX gurus there :-). In any case, more
    REXX users are likely to learn something from your query and the
    replies.

    Regards,

    --Murray
    <Team PL/I>
    ___
    * MR/2 2.30 #120 * One printed manual is worth a thousand INF files

    --- Maximus/2 3.01
    * Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
  • From Murray Lesser@1:106/2000 to Bryan Rubingh on Fri Aug 4 00:04:00 2000
    (Excerpts from a message dated 08-03-00, Murray Lesser to Bryan Rubingh)

    Hi Brian--

    (Excerpts from a message dated 08-02-00, Bryan Rubingh to All)


    I've written a REXX program which reads one file, changes a few
    >lines as it reads and writes to a second file, doing the above one
    >line at a time. When it reaches the end of the first file, I want
    >to copy the second file (the one REXX created) to another location.
    >I've tried just doing:
    >copy file2 file3
    >but I get an OS/2 error when running the program that file2 is in
    >use. Is there any way in REXX to close the file so that the OS can
    >copy it?

    You have some other error, if file2 is the newly-created file.
    >There is no OS/2 restriction against copying an open file to another
    >file. There _is_ a restriction against copying a file _to_ an open
    >file.

    Sorry, Brian. You were right and I was wrong. You cannot use an
    open file in a copy command, in either direction. I guess I am just
    getting forgetful in my old age :-(. But (as you have also been told by others), you do use the 'command' option of the REXX STREAM function to
    close a file.

    Regards,

    --Murray
    <Team PL/I>
    ___
    * MR/2 2.30 #120 * Never say "always" or "never"

    --- Maximus/2 3.01
    * Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)
  • From Baden Kudrenecky@1:153/908 to Bryan Rubingh on Fri Aug 4 01:09:00 2000
    Responding to Bryan Rubingh from 1928-08-02 concerning close file in REXX, on Os2prog

    Hi Bryan:

    I've written a REXX program which reads one file, changes a few lines as
    it reads and writes to a second file, doing the above one line at a
    time. When it reaches the end of the first file, I want to copy the
    second file (the one REXX created) to another location. I've tried just doing:
    copy file2 file3
    but I get an OS/2 error when running the program that file2 is in use.
    Is there any way in REXX to close the file so that the OS can copy it?

    There is an OS/2 Rexx forum, but all that you have to do is
    explicitly close the file with a call to "rc = lineout('file')"
    This is documented in the Rexx IPF file.


    hasta luego, baden
    baden@unixg.ubc.ca
    http://baden.nu/



    ___
    X KWQ/2 1.2i X My mouse pad supports Java!

    --- Maximus/2 3.01
    * Origin: T-Board (1:153/908)
  • From Eddy Thilleman@2:280/5143.7 to Bryan Rubingh on Sat Aug 5 09:52:38 2000
    Hello Bryan,

    Wednesday 02 August 2000 00:00, Bryan Rubingh wrote to All:

    I've written a REXX program which reads one file, changes a few lines
    as it reads and writes to a second file, doing the above one line at a time. When it reaches the end of the first file, I want to copy the
    second file (the one REXX created) to another location. I've tried
    just doing: copy file2 file3 but I get an OS/2 error when running the program that file2 is in use. Is there any way in REXX to close the
    file so that the OS can copy it?

    The stream function is one way:

    check = stream( fname, 'C', 'close' )
    I use Object REXX. There are differences in the stream function in classic REXX
    and in Object REXX.

    To make it easier to use, I've made a function around it:

    /* function CloseFile( fname ) */
    CloseFile: procedure
    parse arg fname
    check = stream( fname, 'C', 'close' )
    if (check == 'READY') | (check == 'READY:') then
    result = 1
    else
    do
    result = 0
    say "Error closing" fname":" stream( InFile, 'D' ) /* display description about possible error */
    end
    return

    Another way is LINEOUT('anyfile') to close 'anyfile'.


    Greetings -=Eddy=-

    email: ethilleman@zonnet.nl
    e.thilleman@hccnet.nl
    eddy.thilleman@net.hcc.nl

    ... Real programmers write to disks with magnets...
    --- GoldED/2 3.0.1
    * Origin: Warp 3, Scotty... and close those damn Windows! (2:280/5143.7)
  • From Bryan Rubingh@1:109/347 to Eddy Thilleman on Mon Aug 14 17:00:00 2000
    Quoting Eddy Thilleman to Bryan Rubingh <=-

    The stream function is one way:

    Another way is LINEOUT('anyfile') to close 'anyfile'.

    Thanks much. I didn't use stream to open it, I just used lineout, so I
    think the lineout should be what I want to close it.

    Thanks,
    Bryan Rubingh


    ... Rube Ink - Custom Programming/Computer Solutions

    ___ Blue Wave/QWK v2.20

    --- Maximus/2 2.02
    * Origin: OS/2 Shareware BBS, telnet://bbs.os2bbs.com (1:109/347)
  • From Bryan Rubingh@1:109/347 to Baden Kudrenecky on Mon Aug 14 17:00:02 2000
    Quoting Baden Kudrenecky to Bryan Rubingh <=-

    There is an OS/2 Rexx forum, but all that you have to do is

    Thanks. I didn't realize that. I must not be downloading that forum.
    Time to sign up.

    Bryan Rubingh


    ... Rube Ink - Custom Programming/Computer Solutions

    ___ Blue Wave/QWK v2.20

    --- Maximus/2 2.02
    * Origin: OS/2 Shareware BBS, telnet://bbs.os2bbs.com (1:109/347)
  • From MIKE RUSKAI@1:3603/140 to BRYAN RUBINGH on Sun Aug 20 01:29:00 2000
    Some senseless babbling from Bryan Rubingh to Eddy Thilleman
    on 08-15-00 00:00 about close file in REXX...

    Quoting Eddy Thilleman to Bryan Rubingh <=-

    The stream function is one way:

    Another way is LINEOUT('anyfile') to close 'anyfile'.

    Thanks much. I didn't use stream to open it, I just used lineout, so
    I think the lineout should be what I want to close it.

    That doesn't make any sense.

    You shouldn't count on lineout() with no data to close a file.

    Just use stream() to close the file. Using it to open the file is also a
    good idea, so you can test whether or not the open was successful. If you
    rely on linein() to implicitly open the file, you won't know it failed,
    except by the fact that no data was read.

    Mike Ruskai
    thannymeister@yahoo.com


    ... HAL 9000: Help me, Dave. I can't run under Windows, Dave.

    ___ Blue Wave/QWK v2.20
    --- Platinum Xpress/Win/Wildcat5! v3.0pr3
    * Origin: Get all your fido mail here.. www.docsplace.org (1:3603/140)
  • From Eddy Thilleman@2:280/5143.7 to Bryan Rubingh on Wed Aug 23 04:37:20 2000
    Hello Bryan,

    Sunday 20 August 2000 08:29, MIKE RUSKAI wrote to BRYAN RUBINGH:

    Just use stream() to close the file. Using it to open the file is
    also a good idea, so you can test whether or not the open was
    successful. If you rely on linein() to implicitly open the file, you
    won't know it failed, except by the fact that no data was read.

    I agree with Mike, and test explictly on errors from opening the file, reading from the file, writing to the file, and closing the file, all with the stream function. I've put all this in functions for easy use. If you want, I can post in OS2REXX.


    Greetings -=Eddy=-

    email: ethilleman@zonnet.nl
    e.thilleman@hccnet.nl
    eddy.thilleman@net.hcc.nl

    ... Bimbouy: A blonde in the water.
    --- GoldED/2 3.0.1
    * Origin: Computer... Smoke... Uhh Ohh (2:280/5143.7)