04 Aug 95 02:33, Jason Eicholtz wrote to All:
JE> Hello.. I wrote this code, but have been unable to get it to scroll
JE> properly.. the TEXT.TXT file mentioned in it contained 40 lines, which
JE> were numbered as "This is line " etc, all the way to 40. For
JE> some reason, it skips 16, and jumps 1 line when it begins to scroll. I
JE> checked the file, and line 16 is there, but for some reason it doesn't
JE> display that one. Here's the code:
JE> $ERROR BOUNDS
JE> $DYNAMIC
JE> DEFINT A-Z
JE> width 80,25
JE> cls
JE> open "Test.TXT" for input as #1
JE> a%=1
JE> do until EOF(1)
JE> line input #1, a$
JE> INCR a%
JE> loop
JE> DIM wow$(a%)
JE> seek #1,0
JE> for x = 1 to a%-1
JE> line input #1, wow$(x)
JE> next x
JE> close #1
JE> for x = 1 to 25
JE> print wow$(x)
JE> next x
JE> location%=1
JE> Mine:
JE> do
JE> a$=inkey$
JE> if ucase$(a$)="A" then gosub down
JE> if ucase$(a$)="Q" then gosub up
JE> loop
JE> up:
JE> if location%=1 then return else decr location%
JE> ! MOV AH, &H07 'AH = Service Number, in this case, scroll up
JE> ! MOV AL, &H01 'AL = Lines to scroll
JE> ! MOV BH, &H00 'BH = fill character (0= nothing, or blank)
JE> ! MOV CH, &H00 'CH = upper row
JE> ! MOV CL, &H00 'CL = left column
JE> ! MOV DH, &H25 'DH = lower row
JE> ! MOV DL, &H80 'DL = right column
JE> ! INT &h10
JE> locate 1,1
JE> print wow$(location%);
JE> return
JE> down:
JE> if location%+25=a% then return else incr location%
JE> ! MOV AH, &H06
JE> ! MOV AL, &H01
JE> ! MOV BH, &H00
JE> ! MOV CH, &H00
JE> ! MOV CL, &H00
JE> ! MOV DH, &H25
JE> ! MOV DL, &H80
JE> ! INT &h10
JE> locate 24,1
JE> print wow$(location%+24);
JE> return
Hello Jason!
Just a couple of things, it's always a good idea to save DS and BP when
making any kind of DOS service calls. You never know what you're going to get
on return...
Hope this helps you...
=== Cut ===
$ERROR BOUNDS
$DYNAMIC
DEFINT A-Z
cls
open "Test.Txt" for input as #1
%True = -1
c%=0 'Counter for Number of lines in text file
UpArrow$ = Chr$(0) + Chr$(72) 'Up-Arrow pressed
DnArrow$ = Chr$(0) + Chr$(80) 'Down-Arrow pressed
Esc$ = Chr$(27) 'Esc-Key pressed
Dim StartCol as shared Byte : StartCol = 0
Dim EndCol as shared Byte : EndCol = 79
Dim StartRow as shared Byte : StartRow = 0
Dim EndRow as shared Byte : EndRow = 23
Dim LinesToScroll as shared Byte : LinesToScroll = 1
DIm Location as Integer : Location = 1
do
a$ = ""
line input #1, a$
If a$ "" Then INCR c%
loop until EOF(1) = %True
DIM wow$(c%)
seek #1,0
for x% = 1 to c%
line input #1, wow$(x%)
next x%
close #1
for x% = 1 to 24
print wow$(x%)
next x%
Mine:
do
KB$=INKEY$
if KB$=UpArrow$ then gosub Up
if KB$=DnArrow$ then gosub Down
loop Until KB$ = Esc$ 'Esc key pressed! ... End Program ...
CLS
Print "Program ended normally...
END ''''''''''''''''
up:
if location%=1 then return else decr location%
! PUSH BP ;Save the base pointer
! PUSH DS ;and the data segment when calling this function
! MOV AH, &H07 ;AH = Service Number, in this case, scroll up
! MOV AL, LinesToScroll ;AL = Lines to scroll
! MOV BH, &H0 ;BH = fill character (0= nothing, or blank)
! MOV CH, StartRow ;CH = upper row 0 - 24
! MOV CL, StartCol ;CL = left column 0 - 79
! MOV DH, EndRow ;DH = lower row 0 - 24
! MOV DL, EndCol ;DL = right column 0 - 79
! INT &H10 ;Call video service
! POP DS ;Restore the data segment
! POP BP ;and the base pointer
locate 1,1
print wow$(location%);
RETURN
down:
if location% + 24 = c% then return else incr location%
! PUSH BP
! PUSH DS
! MOV AH, &H06
! MOV AL, &H01
! MOV BH, &H00
! MOV CH, StartRow
! MOV CL, StartCol
! MOV DH, EndRow
! MOV DL, EndCol
! INT &h10
! POP DS
! POP BP
locate 24,1
print wow$(location% + 24);
RETURN
=== Cut ===
See'ya
...Lou Sanders
--- GoldED/2 2.50.Beta5+
---------------
* Origin: The Basic OutPost System (1:143/333)
|