How does one change file permissions

Hie. Could someone assist. How do i change file permissions using a method in True Basic. I want the method to accept one parameter, then if that value passed is correct, change file permissions to read and write allowed.

thanks in advance

Comments

How does one change file permissions

see below

re: file permissions

Not sure exactly what you are looking for here, but if it choosing between the True Basic ACCESS settings (OUTIN, INPUT, OUTPUT), that could be done with the SELECT CASE structure or just an IF stucture based on the parameter you want to test. Just set a text variable, ACC$ for example, with one of the ACCESS keywords based on your parameter before opening the file.

If you have something else in mind, then please elaborate.

rwt

re:

Thanks for you reply. I would like create a sub which expects a password, then if correct password, make the following files on the system readable and writable. Sorry am new to Basic so just created a dummy method below showing the logic i want. Thanks in advance.

sub allowaccesstofiles(S$)

if(S$="password")
{

Dir "\"
Read Unlock
Write Unlock
File "region"
Read Unlock
Write Unlock
File "country"
End Dir

}

End sub

re: file permissions

The general format for opening files in TrueBasic is

OPEN #1: NAME (filename), ORG (filetype), CREATE (new,old, newold), ACCESS (outin,input,output)

You can deny all access with a statement like

IF S$ = password$ then
OPEN #1: NAME etc.
else
PRINT "You do not have permission to access this file"
end if

If you would want to give read access to everyone, but write access only to those with the password you could set a text variable, say ACC$ something like:

If S$ = password$ then
let ACC$ = "OUTIN"
else
let ACC$ = "INPUT"
end if

then your file OPEN statements would include ACCESS ACC$. The advantage to the ACC$ variable is that you can use it for all file access in your program and reduce the number of lines needed in the decision logic.

Refer to the manual chapter on Files for DATA Input and Output (Chapter 12 in my GOLD documents).

rwt