Example Using C or Assembly to Scroll Text for FORTRAN

ID: Q62885


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.1, 5.0, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 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
X
    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 query words: kbinf 5.00 5.10 mixed language

Keywords :
Version : :4.1,5.0,5.1
Platform :
Issue type :


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