Microsoft KB Archive/79883

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 18:01, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


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

Article ID: 79883

Article Last Modified on 8/16/2005



APPLIES TO

  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 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
                


Additional query words: QuickBas BasicCom 4.50 7.00 7.10

Keywords: KB79883