Announcement

Collapse
No announcement yet.

Delete Text From File

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aldo Cavini
    replied
    Remember under Windows NT, by default, APIs like WritePrivateProfileString work on the registry. To be SURE I'm working on a INI file, I work on the file by-hand.

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

    Leave a comment:


  • danny greenwood
    Guest replied
    Thanks for that one!

    Rgds.

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

    Leave a comment:


  • Simon Morgan
    replied
    To send a null string pointer to a procedure, use:
    Code:
    BYVAL %Null
    [This message has been edited by Simon Morgan (edited June 22, 2001).]

    Leave a comment:


  • Neil Hosgood
    replied
    you could try "" as the param or I think $NUL is internal

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

    Leave a comment:


  • danny greenwood
    Guest replied
    Continuing the discussion on the ini file...

    Is this correct?

    CALL WritePrivateProfileString(qSection, qKey, NULL , IniFile1Name)

    All variables are ASCIIZ

    according to ...

    "lpString
    Pointer to a null-terminated string to be written to the file. If this
    parameter is NULL, the key pointed to by the lpKeyName parameter is deleted."

    ..well it can't be cos it wont compile! How do i set that parameter to NULL?

    Danny


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

    Leave a comment:


  • Tom Hanlin
    replied
    It's not possible to delete text from the middle of a file. What you need
    to do is use two files, an input file and an output file. You read data
    from the input file, and only write the parts you want to keep to the output
    file. When the process is complete, if there were no errors, you can delete
    the original input file and rename the output file to the old input file.


    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Per Fimmeland
    replied
    The API's for dealing with INI's may also delete content.

    From MSDN
    Code:
    BOOL WritePrivateProfileString(
      LPCTSTR lpAppName,  // pointer to section name
      LPCTSTR lpKeyName,  // pointer to key name
      LPCTSTR lpString,   // pointer to string to add
      LPCTSTR lpFileName  // pointer to initialization filename
    );
     
    Parameters
      lpAppName 
          Pointer to a null-terminated string containing the name of the section 
          to which the string will be copied. If the section does not exist, 
          it is created. The name of the section is case-independent; the string 
          can be any combination of uppercase and lowercase letters. 
      lpKeyName 
          Pointer to the null-terminated string containing the name of the key to 
          be associated with a string. If the key does not exist in the specified
          section, it is created. If this parameter is NULL, the entire section, 
          including all entries within the section, is deleted. 
      lpString 
          Pointer to a null-terminated string to be written to the file. If this 
          parameter is NULL, the key pointed to by the lpKeyName parameter is deleted. 
      lpFileName 
          Pointer to a null-terminated string that names the initialization file.

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


    [This message has been edited by Per Fimmeland (edited June 21, 2001).]

    Leave a comment:


  • danny greenwood
    Guest started a topic Delete Text From File

    Delete Text From File

    Can anybody give me some pointers on how to delete text from a file.

    I can open the file and read in all the data using LINE INPUT.
    Do i then search the string for the text i want to delete, remove it from the string,
    then output the string back into a text file. Would this work?

    On a similar note, There are API's to write to .ini files and API's to Read from .ini
    files, but there is nothing to delete a key and value from the ini file. How would this
    be accomplished?

    Ta!

    Danny

    ------------------
Working...
X
😀
🥰
🤢
😎
😡
👍
👎