Cannot Directly Pass Array from FORTRAN to Basic

ID: Q27479


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
  • Microsoft BASIC Professional Development System (PDS) for MS-DOS, versions 7.0, 7.1
  • Microsoft QuickBASIC for MS-DOS, versions 4.0, 4.0b, 4.5


SUMMARY

There is no direct way to pass an array from FORTRAN to a Basic routine. One method that can be used is to set up a fixed length string whose length is the number of bytes in the array being passed. The characters of the string can then be converted to numbers using the CVI, CVL, CVS, or CVD functions. Values may be changed in the array using the MKI$, MKL$, MKS$, or MKD$ functions.


MORE INFORMATION

The Basic program is as follows:


DECLARE SUB forsub ()
OPTION BASE 1
CONST bytes = 20          ' Total number of bytes in array.
                          ' (number of elements * bytes per element)
TYPE arrsize
  ele AS STRING * bytes   ' Sets up consecutive bytes in memory to store
the
END TYPE                  ' whole array from FORTRAN.

CALL forsub


SUB subbas (a AS arrsize)
  size% = 10              ' Number of elements in array.
  elem% = 2               ' Number of bytes in each element.
  DIM arr%(size%)

' This loop converts the FORTRAN array into an array that Basic can use.
' The CVI function should be replaced by a CVL, CVS, OR CVD function if
' the array is not an integer array. If the array is a string array, only
' the MID$ function needs to be used.

  FOR i = 0 TO size% - 1
    arr%(i + 1) = CVI(MID$(a.ele, i * elem% + 1, elem%))
  NEXT i

  FOR i = 1 TO size%
    PRINT arr%(i)
  NEXT i
END SUB 
The FORTRAN subroutine is as follows:

       INTERFACE TO SUBROUTINE SUBBAS (N1)
       INTEGER*2 N1 [NEAR] (10)
       END

       SUBROUTINE FORSUB
       INTEGER*2 A [NEAR] (10)
       DO 10 I = 1, 10
   10  A(I) = I
       A(5) = 99
       A(10) = 99
       CALL SUBBAS(A)
       END 
The OUTPUT is as follows:
1
2
3
4
99
6
7
8
9
99

Additional query words: VBmsdos QuickBas BasicCom

Keywords :
Version : MS-DOS:1.0,4.0,4.0b,4.5; :7.0,7.1
Platform : MS-DOS
Issue type :


Last Reviewed: December 4, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.