HTBasic Help
×
Menu
Index

lock Example

10    CLEAR SCREEN
20    PRINT "*** Lock Test ****"
30    PRINT
40    CREATE "test.txt",100
50    DIM Test$[100]
60    ASSIGN @File TO "test.txt";FORMAT ON
70    PRINT "CAT after assignment..."
80    CAT "test.txt";NO HEADER
90    OUTPUT @File;"This is the contents of test.txt"
100   RESET @File
110   ENTER @File;Test$
120   PRINT
130   PRINT Test$
140   PRINT
150   LOCK @File;CONDITIONAL Error                         !This locks a file while you are working on it.
160   PRINT "CAT after lock..."
170   CAT "test.txt";NO HEADER
180   PRINT
190   PRINT "Lock result is";Error
200   UNLOCK @File                                         !This unlocks the file.
210   PRINT
220   PRINT "CAT after unlock..."
230   CAT "test.txt";NO HEADER
240   ASSIGN @File TO *                                    !This will also unlock the file. Comment out the unlock
250   PRINT                                                !statement to show this.
260   PRINT "CAT after file is closed..."
270   CAT "test.txt";NO HEADER
280   PURGE "test.txt"
290   END