SPONSORS:






User Tag List

Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    May 2001
    Location
    Santa Clara, CA, USA
    Posts
    57
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Replacing a line in a File

    I want to replace a whole line in a batch file using silk. Can anyone help me in doing that .
    This is what I am doing.
    Opening the File
    Getting the Exact line I want and reading it into a String
    Appending the required text to the string
    Now issue is how do i replace the line with the new line

    HFILE hFileHandle = FileOpen ("env.bat", FM_UPDATE)
    while (FileReadLine (hFileHandle, sLine))
    [-] if(SubStr(sLine,1,13) == "SET CUSTOM")
    [ ] sLine = sLine+"test_data"
    [ ] FileWriteLine (hFileHandle, sLine)
    [ ] break
    [ ] FileClose(hFileHandle)

    The above code adds another line and does not replace the old line

    Any help is appreciated

  2. #2
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Replacing a line in a File

    this is how i would do it, in psuedocode...

    ------------------



    [This message has been edited by BrianCarroll (edited 10-10-2001).]

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Location
    Elizabeth, CO, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Replacing a line in a File

    A better way to handle this would be to read the file into a LIST OF STRING variable using ListRead, replacing the line in the LIST OF STRING, and then writing the file back out using ListWrite.

    Something like....

    I hope this helps.

    - Dave


    ------------------
    Amelior Technology
    dreed@ameliortech.com
    WaltzingRhino.com
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:19 PM.

Copyright BetaSoft Inc.