QuickBasic Cursor Position Incorrect after Interlanguage Write (40361)






This article was previously published under Q40361

SUMMARY

If a Microsoft QuickBasic program calls a subroutine or function written in another language (Microsoft C, Pascal, Assembly, or FORTRAN) that writes information to the screen, the QuickBasic cursor position is not updated.

This information applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and Microsoft Basic PDS Version 7.00 for MS-DOS and OS/2.

MORE INFORMATION

The sample program below calls a FORTRAN subroutine. The FORTRAN subroutine starts writing to the screen at the point where QuickBasic finishes.

This program example's printout is readable. The FORTRAN information is printed on line 10 and the Basic information is printed on lines 1 and 2. However, if you remove the second LOCATE statement, both FORTRAN and Basic print on line 10.

The following is a code example:
DECLARE SUB forsub (BYVAL addr%, BYVAL addr2%, x&, y&)
DIM b%(3000)                'Needed if any string is changed
COMMON /nmalloc/ b%()

B$ = "there     "     'FORTRAN expects these to be 10 long
a$ = "hello     "     'Allocate space for the string 10.
x&= 1
y&= 2
CLS
LOCATE 10, 1
CALL forsub(SADD(a$),SADD(b$), x&, y&)
LOCATE 1, 1
PRINT a$;" "; b$, x&, y&
				
The following is the FORTRAN subroutine:
       SUBROUTINE FORSUB(A, B, C, D)
       CHARACTER*10 A [NEAR]
       CHARACTER*10 B [NEAR]
       INTEGER*4 C [NEAR]
       INTEGER*4 D [NEAR]
       WRITE(*,*) A, B, C, D
       A = 'hi there '
       B = 'lets talk'
       C = 3
       D = 4
       END
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB40361