この例では、ファイルを作成し、SetFileAttr を呼び出してその属性を読み込み専用、システム、隠しファイルに設定し、GetFileAttr を呼び出してファイルの属性を調べます
%Include "lsconst.lss"
Dim fileNum As Integer, attr As Integer
Dim fileName As String, msg As String
fileNum% = FreeFile()
fileName$ = "data.txt"
Open fileName$ For Output As fileNum%
Close fileNum%
SetFileAttr fileName$, ATTR_READONLY + ATTR_SYSTEM + _ ATTR_HIDDEN
attr% = GetFileAttr(fileName$)
If (attr% And ATTR_READONLY) Then
msg$ = msg$ & " Read-Only "
Else
msg$ = msg$ & " Normal "
End If
If (attr% And ATTR_HIDDEN) Then msg$ = msg$ & " Hidden "
If (attr% And ATTR_SYSTEM) Then msg$ = msg$ & " System "
If (attr% And ATTR_DIRECTORY) Then msg$ = msg$ & " Directory "
Print msg$
SetFileAttr fileName$, ATTR_NORMAL ' Reset to normal.
Kill fileName$