ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
GET and PUT Statements (File I/O) Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the GET statement to display the contents of a newly
' created random-access file that contains student names and corresponding
' test scores. The PUT statement is used to store the values in the file.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 TYPE TestRecord
     Student AS STRING * 20
     Score AS SINGLE
 END TYPE
 
 DIM MyClass AS TestRecord
 
 OPEN "FINAL.DAT" FOR RANDOM AS #1 LEN = LEN(MyClass)
 MyClass.Student = "MarySa"
 MyClass.Score = 99
 PUT #1, 1, MyClass
 CLOSE #1
 OPEN "FINAL.DAT" FOR RANDOM AS #1 LEN = LEN(MyClass)
 GET #1, 1, MyClass
 PRINT "STUDENT:", MyClass.Student
 PRINT "SCORE:", MyClass.Score
 CLOSE #1
 KILL "FINAL.DAT"