"Field Statement Active" (Error 56) on Basic PUT Statement (79883)



The information in this article applies to:

  • Microsoft QuickBASIC 4.5
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1

This article was previously published under Q79883

SUMMARY

Error 56, "Field Statement Active," will occur on a PUT statement if you attempt to PUT a variable DIMensioned as a TYPE record structure, to a RANDOM file for which there is an active FIELD statement.

If a file has been FIELDed, you must use the FIELD variable(s) to PUT or GET information to or from the file. To use a TYPE variable, you must first CLOSE the file and then reOPEN it.

This information applies to Microsoft QuickBasic version 4.5 for MS-DOS and Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS and MS OS/2.

MORE INFORMATION

If you want to use the FIELD statement and a TYPE structure at the same time, the file must be closed and reopened when you want to switch between using the FIELD statement and the TYPE structure.

Code Example

' This program will give the error message "Field Statement
' Active" on the PUT statement

TYPE putType
  s AS STRING * 12
END TYPE

DIM yoke AS putType

OPEN "thefile.txt" FOR RANDOM AS #1
FIELD #1, 12 AS x$                      'FIELD active

LSET x$ = "nirvana"
PUT #1                          'PUT using FIELD variable

yoke.s = "soundgarden"

' Take out remarks on next two Basic lines to allow program to
' run, otherwise error 56 will occur on the next PUT:
' CLOSE #1
' OPEN "thefile" FOR RANDOM AS #1
'(closing and reopening file disables FIELD)

PUT #1, , yoke
CLOSE
END
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB79883