Article ID: 37320
Article Last Modified on 1/8/2003
APPLIES TO
- Microsoft QuickBasic Compiler for Macintosh 1.0
This article was previously published under Q37320
SYMPTOMS
The OCT$ and HEX$ functions return erroneous results when the following three conditions are met:
- The parameter passed to OCT$ or HEX$ is an array element.
- The array is dynamic.
- 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:
- Assign the array element to a temporary variable and pass the temporary variable to the OCT$ or HEX$ function.
- Make the array static.
- Pass the array element to the OCT$ or HEX$ function in an expression, such as OCT$(array%(1)+null%).
MORE INFORMATION
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"):
- Include The Runtime Code
- Launch After Compiling
- Use Default Window
- 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 END
Additional query words: MQuickB
Keywords: kbbug KB37320