Microsoft KB Archive/59757

From BetaArchive Wiki
Knowledge Base


BUG: IF THEN SUBname Causes "Undefined Label"; Requires CALL

Article ID: 59757

Article Last Modified on 11/21/2006

This article was previously published under Q59757

SYMPTOMS

The IF ... THEN SUBName statement causes an "Undefined label" error in QuickBasic for the Macintosh when attempting an implicit call to the specified SUBprogram.

To work around this error, use an explicit CALL statement for single-line IF statements, as follows:

   IF ... THEN CALL SUBName
                

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The problem occurs because the IF ... THEN Label statement does not require a GOTO statement for alphanumeric labels in QuickBasic for the Macintosh . (Note that Microsoft QuickBasic for MS-DOS requires a GOTO clause for alphanumeric labels in the IF ... THEN GOTO Label statement.)

Since the GOTO is not required, the simple alphanumeric could be interpreted as a label or an implicit CALL to a SUB. By using the explicit CALL statement, the ambiguity of the statement is resolved.

Code Example

The following code example produces an "Undefined label" error on the first IF statement. If the first IF is removed, the second IF works correctly:

     IF 1 = 1 THEN SubName       'Causes "Undefined label" error
   IF 1 = 1 THEN CALL SubName  'No error for this line
   END

   SUB SubName STATIC
      PRINT "In Sub"
   END SUB

                


Additional query words: MQuickB

Keywords: kbbug KB59757