Microsoft KB Archive/40718

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


Basic TYPE...END TYPE Must Be Physically at Top of Program

Article ID: 40718

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Professional Development System 7.0



This article was previously published under Q40718

SUMMARY

The QuickBasic TYPE...END TYPE statement must be physically at the top of the program. If it isn't, the program may not compile correctly. This information applies to QuickBasic Versions 4.00, 4.00b, and 4.50, Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.

The code example shown below does not compile correctly. In the QB.EXE editor, an error "Identifier cannot include a period" is reported on Line 2. In BC.EXE, two errors are reported, as follows:

Variable name not unique

Type Mismatch

To correct the program, move the TYPE ... END TYPE block and the DIM statement before the use of the variable. It is best to place these types of statements at the beginning of the program.

The following is sample code:

GOSUB initvar
  PRINT x.str
END

initvar:
        TYPE user
            str AS STRING * 10
        END TYPE
        DIM x AS user
        x.str = "hello"
RETURN
                


Additional query words: QuickBas BasicCom

Keywords: KB40718