Example Using C or Assembly to Scroll Text for FORTRAN

Last reviewed: July 17, 1995
Article ID: Q62885
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS and OS/2 versions 4.1, 5.0 and 5.1

SUMMARY

With an OUTTEXT call, it is not possible to embed CR/LF characters to enforce scrolling of text on the screen. To scroll the text, an assembler or C routine may be used as follows:

  1. Use SETTEXTPOSITION to position the cursor on the screen.

  2. Use OUTTEXT to display the output at that position.

  3. Call an Assembly or C routine to scroll the screen by one line.

  4. Return to step 1 above, positioning the cursor at the same location on the screen.

MORE INFORMATION

The following code sample illustrates the use of the assembly routine:

Sample Code (.for)

       interface to subroutine scroll_line()
       end
       include 'fgraph.fi'
       include 'fgraph.fd'
       record/rccoord/curpos
c
       call settextposition (10,20,curpos)
       call outtext('Hello1')
c
       call scroll_line()
c
       call settextposition (10,20,curpos)
       call outtext ('Hello2')
       end

The following is the code segment of the assembly module:

Sample Code (.asm)

.model large,fortran

.code

scroll_line proc far

     push bp
     mov bp, sp
     mov ah,6          ;function 6H
     mov al,1          ;number of lines to scroll
     mov ch,0          ;row of top left corner
     mov cl,0          ;col of top left corner
     mov dh,24         ;row of bottom right corner
     mov dl,79         ;col of bottom right corner
     mov bh,7          ;attribute of line
     int 10h           ;interrupt 10h
     pop bp
     ret
scroll_line endp
     end

To use the C subroutine, only the interface statement of the FORTRAN module should be modified to read as follows:

       interface to subroutine scroll_line [FAR,C] ()
       end

The following is the code segment of the C module:

Sample Code (C)

#include <stdio.h>
#include <dos.h>

union REGS reg;

void scroll_line()
{

/*
 *  The registers have the same significance as those in
 *  the assembly-language routine above.
 */

  reg.h.ah = 6;     // function 6H
  reg.h.al = 1;     // number of lines to scroll
  reg.h.bh = 0x7;   // attribute of line
  reg.h.ch = 0;     // row of top left corner
  reg.h.cl = 0;     // column of top left corner
  reg.h.dh = 24;    // row of bottom right corner
  reg.h.dl = 79;    // row of top right corner

  int86(0x10, &reg, &reg);
  return;
}

The following is the MAKE file when the assembly module subroutine is used:

Makefile (Assembly)

all=1.obj 2.obj

update: 1.for

    fl /Zi /c 1.for

update: 2.asm
    masm /Zi 2.asm;

update: $(all) link /co $(all),,,/nod graphics llibfer;

The following is the MAKE file when the C module subroutine is used:

Makefile (C)

all=1.obj 2.obj

update: 1.for

    fl /Zi /c 1.for

update: 2.c
    cl /AL /Zi /c 2.c

update: $(all)
    link $(all)/co,,,/nod /noe graphics llibfer llibcer;


Additional reference words: kbinf 5.00 5.10 mixed language
KBCategory: kbprg kbinterop kbcode
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.