Microsoft KB Archive/37320

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base

BUG: Dynamic Array Element in OCT$/HEX$ Return Bad If Compiled

Article ID: 37320

Article Last Modified on 1/8/2003


  • Microsoft QuickBasic Compiler for Macintosh 1.0

This article was previously published under Q37320


The OCT$ and HEX$ functions return erroneous results when the following three conditions are met:

  1. The parameter passed to OCT$ or HEX$ is an array element.
  2. The array is dynamic.
  3. The program is compiled.

The code sample below demonstrates the problem.

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

The OCT$ and HEX$ functions work correctly when run within the QuickBasic environment. To work around this problem in the compiled version, do any of the following:

  1. Assign the array element to a temporary variable and pass the temporary variable to the OCT$ or HEX$ function.
  2. Make the array static.
  3. Pass the array element to the OCT$ or HEX$ function in an expression, such as OCT$(array%(1)+null%).


Both the decimal math and binary math compiled versions demonstrate the problem. Compile the program below with the following options selected (i.e., do not compile with "Make All Arrays Static"):

  1. Include The Runtime Code
  2. Launch After Compiling
  3. Use Default Window
  4. Use Default Menu

The following is a code example:

DIM array%(1)
array%(1) = 0
'      Incorrect output using array element:
PRINT OCT$(array%(1))      'Output is: 37774600000
PRINT HEX$(array%(1))      'Output is: FFF30000
'      Correct output with a temporary variable:
temp% = array%(1)             'Assign to a temporary variable
PRINT OCT$(temp)             'Output is: 0
PRINT HEX$(temp)             'Output is: 0
'      Correct output with an expression:
null% = 0
PRINT OCT$(array%(1)+null%)      'Output is: 0
PRINT HEX$(array%(1)+null%)      'Output is: 0

Additional query words: MQuickB

Keywords: kbbug KB37320