The !CHMOD() subroutine sets the mode value (permissions) for a given pathname.
CALL !CHMOD(status, pathname, modes)
The !CHMOD() subroutine is equivalent to use of the Linux chmod command to set the mode value (permissions) for a given file. If successful, the status argument is set to True. If unsuccessful, status is returned as False. The subroutine is not applicable to Windows systems and will always return False on such systems.
The subroutine argument structure allows it to be defined and used as a function as shown in one of the examples below.
File permission values in Linux are usually represented as a three digit octal value with one digit for the permissions applicable to the file owner, one for other members of the group to which the file is assigned, and one for the permissions applicable to all other users. Each digit is formed from adding three elements; 4 for read permission, 2 for write permission, and 1 for execute permission. The !CHMOD() subroutine modes argument is a character string containing this three digit octal value. Because of the type variant nature of QMBasic, the modes can also be written as a numeric value which will be treated as a character string internally by the subroutine.
CALL !CHMOD(OK, PATH, "744")
DEFFUN CHMOD(PATH, MODES) CALLING "!CHMOD"
OK = CHMOD(PATH, 744)
Both of these examples set the permissions associated with the file identified by PATH to 744 (rwxr--r--).