Alpha Video Training
Results 1 to 7 of 7

Thread: Appending files with files(Non A5)

  1. #1
    Nathan White
    Guest

    Default Appending files with files(Non A5)

    I would like to know how to use an Xbasic command to append two .txt files. I know in DOS that two files can be appended by using Filename1=Filename1 + Filename2 type format. Does A5 have anything like this, without having to drop the info into a database?

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Appending files with files(Non A5)

    Alpha has methods to obtain file pointers, read, and write to these files. The syntax is rather obtuse. Check the online documentation.

    If you are familiar with the DOS methods, why not use the sys_shell() command to run a batch command to join the files?

  3. #3
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default RE: Appending files with files(Non A5)

    Nathan,

    The answer is probably yes. You can read into 2 BLOBs (Binary Large Objects) from files to variables, concatonate them using + and then write the file back out.

    If I have time, I'll try this out later tonight.

    Regards,

    Ira J. Perlow
    Computer Systems Design & Associates
    csda@mediaone.net

  4. #4
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default RE: Appending files with files(Non A5)

    For text files Alpha Five's file.read_line() and file.write_line()methods should permit you to easily build a short script which

    - reads the lines from the first file and writes them to a new file
    - reads the lines from the second file and writes them to the new file

    You would wind up with a third file which contains all the lines from both of the source files.

  5. #5
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default RE: Appending files with files(Non A5)

    Tom,

    That would work too! (I didn't notice the concatonate 2 text files together).
    For any type of file you could also use the fule.readb() and file.writeb() to read byte by byte for binary files (e.g. 2 print files). Be careful if you get a null value which might be a chr(0).

    This would not be as fast as using the blob method (which I have not tried yet)

    Regards,

    Ira J. Perlow
    Computer Systems Design & Associates
    csda@mediaone.net

  6. #6
    Nathan White
    Guest

    Default RE: Appending files with files(Non A5)

    I appreciate your input. Thank you. I was curious how one would use .readb() if the size of the file wasn't known. The xbasic manual implies that a value must be entered into the () of the function. Is there a method to finding this value and entering it into the function?



    NATHAN

  7. #7
    Nathan White
    Guest

    Default RE: Appending files with files(Non A5)

    Tom:
    Thanks for the response. What I ended up doing was opening the main file and having the pointer read each line until it hit the end of the file. At this point I open the second file. I read a line from the second file and write it to the main file (thus, putting the first lines of the second file at the end of the main file. Just like appending). However, there is one small problem. I get an arrow character before my first entry. I'm assuming this is some char or EOF char. How would I rid myself of this little nuisance? or should I change my approach. I'm trying to avoid creating a third file (simplicity).

    Sincerely,



    NATHAN WHITE

Similar Threads

  1. Appending Files from a selection
    By Ted Giles in forum Alpha Five Version 6
    Replies: 2
    Last Post: 10-12-2005, 07:25 PM
  2. What are these files?
    By Daniel Earley in forum Alpha Five Version 5
    Replies: 2
    Last Post: 02-01-2003, 05:06 PM
  3. .{s} files
    By John Gamble in forum Alpha Five Version 5
    Replies: 3
    Last Post: 01-20-2003, 03:10 PM
  4. *.ASX Files???
    By Mike Konoff in forum Alpha Five Version 4
    Replies: 1
    Last Post: 01-23-2002, 05:12 AM
  5. $$******.ASX files??
    By Becky McNichols in forum Alpha Five Version 4
    Replies: 4
    Last Post: 06-13-2000, 01:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •