1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Append something entered to a file?

Discussion in 'Support' started by vefatica, Feb 28, 2011.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    I have a long-running batch file which produces a log file. I can interrupt the batch file's main loop (by looking at keystrokes) and do administrative things (set parameters with ESET, get status info, et c.) then continue. I'd like to add the ability to put a hand-written notation in the log file.

    So how do I get TCC to accept text from the keyboard and when I'm done (Enter or Ctrl-Z?) write it to a file? [This seems like an ancient technique which I have simply forgotten.]
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    ---- Original Message ----
    From: vefatica
    To: ESFabian@zenge.org
    Sent: Monday, 2011. February 28. 23:02
    Subject: [Support-t-2639] Append something entered to a file?

    | I have a long-running batch file which produces a log file. I can
    | interrupt the batch file's main loop (by looking at keystrokes) and
    | do administrative things (set parameters with ESET, get status info,
    | et c.) then continue. I'd like to add the ability to put a
    | hand-written notation in the log file.
    |
    | So how do I get TCC to accept text from the keyboard and when I'm
    | done (Enter or Ctrl-Z?) write it to a file? [This seems like an
    | ancient technique which I have simply forgotten.]

    INPUT?
    --
    Steve
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    That's not exactly whan I was thinking (ESET could be used similarly). I may be wrong, but I seem to recall something like (paraphrasing)

    Code:
    < keyboard >> file  [press Ctrl-Z when done]
    Am I thinking of UNIX?
     
  4. TEA-Time

    Joined:
    Jun 2, 2008
    Messages:
    282
    Likes Received:
    1
    COPY CON?
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    On Mon, 28 Feb 2011 23:44:00 -0500, TEA-Time <> wrote:

    |Code:
    |---------
    |< keyboard >> file [press Ctrl-Z when done]
    |---------
    |Am I thinking of UNIX?
    |---End Quote---
    |COPY CON?

    That may be what I was thinking of. Can it append to the file?
     
  6. Kachupp

    Joined:
    Aug 9, 2009
    Messages:
    133
    Likes Received:
    0
    @fileopen[]
    querybox %%stuff
    @fileclose[]
     
  7. Kachupp

    Joined:
    Aug 9, 2009
    Messages:
    133
    Likes Received:
    0
    -----Original Message-----
    From: Kach [mailto:kachupp@gmail.com]
    Sent: Tuesday, 1 March 2011 7:05 p.m.
    To: Kach
    Subject: RE: [Support-t-2639] Append something entered to a file?


    forgot to write that stuff ......lol


    set open_0=%@fileopen[%@unique[],w,t]
    querybox /e %%stuff
    set w=%@filewrite[%open_0,%stuff]
    echo %@fileclose[%open_0]
     
  8. TEA-Time

    Joined:
    Jun 2, 2008
    Messages:
    282
    Likes Received:
    1
    Good question... I guess it does. See the Appending Files section in COPY's help.

    COPY test.txt+CON

    ..appends what's entered to an existing test.txt.
     
  9. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    On Tue, 01 Mar 2011 01:13:36 -0500, TEA-Time <> wrote:

    |That may be what I was thinking of. Can it append to the file?
    |---End Quote---
    |Good question... I guess it does. See the Appending Files section in COPY's help.
    |
    |COPY test.txt+CON
    |
    |..appends what's entered to an existing test.txt.

    Thanks! That seems arcane/obscure but it does what I want. The problem with
    INPUT/ESET is that later, you's have to ECHO the variable to a file and any
    special characters would cause big problems.

    Another question: You end "COPY test.txt+CON" with Ctrl-Z. Is there a way to
    prevent the Ctrl-Z from winding up in the file (another way to terminate the
    input)? I haven't considered it in about 20 years, but today, putting Ctrl-Z in
    a file seems very odd (especially if **any** software is later going to consider
    it EOF).
     
  10. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,730
    Likes Received:
    80
    copy test.txt+con /b test.txt
     
  11. TEA-Time

    Joined:
    Jun 2, 2008
    Messages:
    282
    Likes Received:
    1
    Thanks Rex! I wasn't sure about that.
     
  12. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    170
    Likes Received:
    0
    It depends on how things are added to the file by the batches.

    Ye should use the same method, eg echo 'text' >> logfile

    You could set a subroutine 'note' that simply takes text from the command line, and add it to the file.
     
  13. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    I can't login to the forum site. I enter my userid/password and the same login
    dialog returns.

    - Vince
     

Share This Page