Changing Unix <CTRL>M to DOS


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Changing Unix <CTRL>M to DOS

  1. #1
    Join Date
    Sep 2005
    Posts
    11

    Changing Unix <CTRL>M to DOS

    I have an application that does a "shell" call that opens a cygwin shell and then creates a file from that cygwin shell. As would be expected, the file is created using the Unix <Ctrl>M character as the new line feed. Therefore, when the file is opened (by the same application) later in the application, it sees the contents of the file as a single line.

    That said, what I would like to accomplish is to convert the Unix line feeds to the DOS environment. Is there anyway within VB this can be accomplished?

    I'd appreciate any suggestions . . .
    Thanks,
    kgk

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    you can use the Replace method to change all the <Ctrl>M into vbCrLf
    if the file is small enough you can read it into a string, if not, you have to read smaller pieces.
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Sep 2005
    Posts
    11
    thanks for the quick reply Marco. My problem is I'm quite the novice with VB and I'm not finding much documentation on how I would set this up. Do you have any example code that would help in this - or maybe point me to a place I might find it?
    kgkidd

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    on which part do you need help? Opening the file, read it, using Replace, or display it? Do you have MSDN installed?
    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Sep 2005
    Posts
    11
    No, I'm afraid MSDN is not installed and I'm in such a controlled environment that isn't going to happen. Specifically I'm looking for help on using Replace.
    Thanks Marco
    kgkidd

  6. #6
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    leaving a programmer without MSDN is suicidal...
    at least you have internet access, you can get the help online at www.msdn.com (but itis not the same as hitting F1 on the keyboard!)

    http://msdn.microsoft.com/library/de...fctreplace.asp

    This for example
    Replace$("aSssSw","s","Q",,,vbTextCompare)
    will return "aQQQQw"

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  7. #7
    Join Date
    Sep 2005
    Posts
    11
    Yes, it seems very suicidal here - but that help is exactly what I'm looking for. Thank you very much Marco.

Similar Threads

  1. Alice in Unix Land
    By pwilmarth in forum .NET
    Replies: 0
    Last Post: 11-22-2002, 01:23 PM
  2. UNIX and ASP
    By Alice Claussen in forum ASP.NET
    Replies: 2
    Last Post: 08-08-2002, 02:13 PM
  3. But in the end, it is still UNIX
    By Jeff Jones in forum Open Source
    Replies: 6
    Last Post: 07-11-2002, 11:37 AM
  4. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 01:43 AM
  5. Replies: 0
    Last Post: 02-02-2001, 12:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center