PDA

View Full Version : "kill" command in liberty basic


rrr
Jan 3, 2007, 07:16 AM
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:

LTheobald
Jan 3, 2007, 10:20 AM
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 (http://www.libertybasicuniversity.com/lb3docs/index.html)

rrr
Jan 4, 2007, 01:15 AM
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:


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

Liberty basics helpfiles description:

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 (http://www.libertybasic.com)
Fun fact: I am thirteen :D

Carl Gundel
Jan 11, 2007, 02:37 PM
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:


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 (http://www.libertybasic.com)

rrr
Jan 15, 2007, 04:02 AM
Thank you very much, carl. It's a honor to have been helped by you
*bows deeply*
:D:D:D