Microsoft KB Archive/27480

= Passing FORTRAN COMMON Block to QuickBasic SUBprogram =

Article ID: 27480

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q27480



SUMMARY
The strategy for passing a FORTRAN COMMON block to QuickBasic is to pass the first variable of the FORTRAN COMMON block as a parameter in the CALL to the Basic routine. The Basic program should set up a user-defined-TYPE variable with the same format as the COMMON in FORTRAN. The Basic SUB statement must receive a variable of this type as a formal parameter.



Basic Program
The Basic program is as follows: DECLARE SUB forsub

TYPE CommonDescription a AS INTEGER            'Matches common block in FORTRAN b AS LONG c AS SINGLE d AS DOUBLE END TYPE

CALL forsub

SUB subbas (var AS CommonDescription) PRINT var.a PRINT var.b  PRINT var.c  PRINT var.d END SUB

FORTRAN Subroutine
The FORTRAN subroutine is as follows: INTERFACE TO SUBROUTINE SUBBAS (N1) INTEGER*2 N1 [NEAR] END

SUBROUTINE FORSUB INTEGER*2 A      INTEGER*4 B       REAL*4 C       REAL*8 D

*The common block must be a named common block (any name will do). *The [NEAR] has to be there for it to work.

COMMON /FORBLOCK [NEAR]/ A,B,C,D A = 9 B = 999 C = 99.99 D = 999.999 CALL SUBBAS(A) END

OUTPUT
The OUTPUT is as follows:

9

999

99.99

999.999

Additional query words: QuickBas BasicCom

Keywords: KB27480

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.