Microsoft KB Archive/27486

= CALLing C I/O Routines Does Not Affect QB Cursor Position =

Article ID: 27486

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
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q27486



SUMMARY
Problem:

Microsoft C routines (medium model) linked with a compiled Basic program that do screen output [such as printf (&quot;hello, world.\n&quot;);] do not update the cursor position after returning to the calling Basic program.

For example, after 1) doing a PRINT from Basic, 2) CALLing a C routine that does some printf's, and 3) returning to Basic, the next PRINT statement goes directly after the last Basic PRINT statement, ignoring the \n's (newline characters) from the called C routine.

Response:

This is expected behavior. C routines should not change the Basic cursor position. This information applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler Versions 6.00 and 6.00b, and to Microsoft Basic Professional Development System (PDS) Version 7.00.

To work around this limitation, OPEN &quot;CONS:&quot; as a device in Basic and print to the console (screen) using PRINT# or PRINT# USING in Basic. This forces Basic to go through the operating system's console device instead of using direct writes to video memory.

The following is a code example where a C function doesn't change the cursor position in Basic: 'The following QuickBasic program prints: ' Hello. ' Goodbye.t part of this line gets erased. DECLARE SUB CRoutine CDECL CLS PRINT &quot;Hello.&quot; CALL CRoutine PRINT &quot;Goodbye.&quot;

/* C program */ #include   void croutine {  printf (&quot;The first part of this line gets erased.\n&quot;); }

Additional query words: QuickBas BasicCom

Keywords: KB27486

-

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

© Microsoft Corporation. All rights reserved.