Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Other Programming (https://www.askmehelpdesk.com/forumdisplay.php?f=437)
-   -   "kill" command in liberty basic (https://www.askmehelpdesk.com/showthread.php?t=51992)

  • Jan 3, 2007, 07:16 AM
    rrr
    "kill" command in liberty basic
    It seems the "kill" cmd in liberty basi doesent work because files are interpreted as read only when trying to "kill" them. I tried making a un-install program with the kill cmd, but it didn't work. What to to??
    :confused:
  • Jan 3, 2007, 10:20 AM
    LTheobald
    There might be an unload command for the file you are opening. E.g. loadbmp has a unloadbmp command to unload the file. What command are you using to load the file?

    I got that from searching on the help a bit:
    Liberty BASIC Online Help
  • Jan 4, 2007, 01:15 AM
    rrr
    I guess you misinterpreted the command, you do not use the "kill" command when handling a file, then you use the close *filehandler*
    Kill is used in this way:

    Code:

    print "Enter a valid path for a file so that this program can erase it :)"
    input path$
    kill$(path$)

    Liberty basics helpfiles description:
    Code:

    KILL "filename.ext"
    This command deletes the file specified by filename.ext.  The filename can include a complete path specification.

    Even if path$ leads to a valid file, the file somehow turn into a read-only file. I tried to remove the read-only option, but it still didn't work. It turns out that it had gone back to being a read-only file.
    And thanks for helping me!:D :D :D
    If you are looking for a place to download liberty basic go here:
    Liberty BASIC - Easy Programming for Windows
    Fun fact: I am thirteen :D
  • Jan 11, 2007, 02:37 PM
    Carl Gundel
    Quote:

    Originally Posted by rrr
    it seems the "kill" cmd in liberty basi doesent work because files are interpreted as read only when trying to "kill" them. I tried making a un-install program with the kill cmd, but it didn't work. What to to??
    :confused:

    The file delete command (like KILL) cannot delete read only files. You will probably need to use a function the Windows API to set the read only flag to false.

    SetFileAttributesA looks like the right one.

    Here's a short example:

    Quote:

    FileDialog "Select filename", "*.*", file$
    Call ClearReadOnly file$
    End

    Sub ClearReadOnly File$
    CallDLL #kernel32, "GetFileAttributesA", _
    File$ As Ptr, _
    attr As Long

    If attr <> -1 Then ' check for valid file
    If (attr And _FILE_ATTRIBUTE_READONLY) = 1 Then
    attr = attr - _FILE_ATTRIBUTE_READONLY

    CallDLL #kernel32, "SetFileAttributesA", _
    File$ As Ptr, _
    attr As Long, _
    ret As Long
    End If
    End If
    End Sub

    -Carl Gundel, author of Liberty BASIC
    Liberty BASIC - Easy Programming for Windows
  • Jan 15, 2007, 04:02 AM
    rrr
    Thank you very much, carl. It's a honor to have been helped by you
    *bows deeply*
    :D:D:D

  • All times are GMT -7. The time now is 01:40 PM.