home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 18
/
CD_ASCQ_18_111294_W.iso
/
dos
/
prg
/
pas
/
pscrn55
/
basic.exe
/
DEMOSCR1.BAS
< prev
next >
Wrap
BASIC Source File
|
1994-10-09
|
7KB
|
188 lines
DEFINT A-Z
'$INCLUDE: 'PScreen.Inc' '... Declare functions in PScreen.Obj
' For Microsoft Basics only.
'===================================================
' POWERBASIC USERS: 'un-REM the next few lines
'===================================================
''$INCLUDE "PScreen.Inc" '...declare routines
''$Link "PScreen.Obj" '...essential "screen restore" routines
''$Link "LoadScrn.PBU" '...link our "load screen" routines
'===================================================
' END: POWERBASIC USERS
'===================================================
'***************************************************************************
' DemoScr1.Bas P-Screen demo. Copyright 1994, Rob W. Smetana
'
' Requires:
'
' 1. PScreen.Inc -- an "include file" declaring procedures and functions.
'
' 2. PScreen.Obj -- assembler screen-restore (and other) routines.
'
' 3. LoadScr?.Obj (Microsoft Basics) or LoadScrn.Pbu (PowerBasic).
' ("?" = "4" for QuickBASIC 4.x, "7" for PDS 7.x, or "V" = VB-DOS)
'
' The "load screen" module contains these functions:
'
' DisplayScreen% (...)
' LoadScreen% (...)
' NumberScreensInLib% (...)
'
' 4. A P-Screen screeen library (e.g., Lessons.PSL).
'
'
' Purpose: 1. Show how easy it is to display screens
' from SCREEN LIBRARIES.
'
' 2. Show how to determine # of screens in library.
'
' 3. Demonstrate using function DISPLAYSCREEN(...)
'
' 4. Display screens using function LOADSCREEN(...)
'
' 5. Demonstrate RE-COLORING screens on-the-fly!
' (NOTE: In shareware versions, "re-color"
' does nothing. But please review the code
' below to see how easily you can re-color
' screens on-the-fly.)
'
' 6. Demonstrate how to detect errors and interpret
' ERROR codes.
'
' 7. Demonstrate using psSaveScrn and
' psRestScrn to ALSO save/restore NORMAL
' screens -- not just our compressed screens.
'
'*************************************************************************
COLOR 7, 1: CLS
Call psInitialize:Cls '...for SHAREWARE versions ONLY
'... put something on the screen to demonstrate saving/restoring it
FOR TRow = 1 TO 25
PRINT " Welcome to P-Screen! Press a key . . ."
NEXT
ky$ = INPUT$(1)
'...Allocate a buffer to save/restore the screen.
TRow = 1: LCol = 1: BRow = 25: RCol = 80
'...Use a formula so if you switch to 43- or 50-line screens,
' the screen buffer (integer array) will be large enough.
NumInts = ((BRow - TRow + 1) * (RCol - LCol + 1))
REDIM ScrnBuf%(1 TO NumInts) '...each integer element holds 2 bytes!
'...save the underlying screen
CALL psSaveScrn(TRow, LCol, BRow, RCol, SEG ScrnBuf(1))
CLS
'We'll display screens from one of P-Screen's screen libraries.
'Screen libraries are created with '.PSL'...extensions. If you
'don't include an extension here, '.PSL'...will be assumed.
'...NOTE: Add a PATH if Lessons.Psl isn't on the current drive/directory
LibName$ = "Lessons"
'... get # of screens in screen library
ErrorCode = NumScreensInLib(LibName$)
GOSUB ProcessError '...halt if error occurred
PRINT "... Library ["; LibName$; "] contains"; ErrorCode; " screens. Press a key. . .";
ky$ = INPUT$(1)
FOR ScreenNumber = 1 TO 7
'...Quickly display several screens by number! Note blank screen name.
ErrorCode = DisplayScreen(LibName$, "", ScreenNumber)
GOSUB ProcessError
NEXT
CLS : LOCATE 12, 20: COLOR 16, 7
PRINT "< 7 screens f-a-s-t, and all from disk. >";
ky$ = INPUT$(1)
COLOR 7, 0
CLS
PRINT " You just saw 7 screens displayed from a screen library using function"
PRINT " DisplayScreen. We displayed these screens by NUMBER -- which is easy!"
PRINT
PRINT " When you press a key, we'll display the first 2 screens, but this time: : :"
PRINT
PRINT " 1. We'll use function LoadScreen and then call psRestScrn. "
PRINT " 2. But BEFORE we display the screens, we'll re-color them dynamically!"
PRINT " (Note: In shareware versions, re-color does nothing.)"
PRINT
PRINT " Press a key . . .";
ky$ = INPUT$(1)
CLS
REDIM Arry(0) '...initialize integer array
FOR ScreenNumber = 1 TO 2 '...when displaying screens by number,
'...pass a blank/nul screen name
ErrorCode = LoadScreen(LibName$, "", ScreenNumber, Arry(), LastScreen, Description$, TopRow, LeftCol, BottomRow, RhtCol, NumInts)
GOSUB ProcessError
'...Change color 2 (green on black) to 79 (or any color you like
'...Change color 10 (brite green on black) to 112 (or any color you like
'...In shareware versions, psRecolor does nothing. But note
' how easily YOU can re-color screens in your own programs.
SegAddr& = 256& * ((VARSEG(Arry(1)) * 256&) + VARPTR(Arry(1)))
CALL psRecolor(SegAddr&, NumInts, 2, 79)
CALL psRecolor(SegAddr&, NumInts, 10, 112)
CALL psRestScrn(TopRow, LeftCol, BottomRow, RhtCol, SEG Arry(1))
ky$ = INPUT$(1)
NEXT
'...now restore the underlying "welcome" screen
CALL psRestScrn(TRow, LCol, BRow, RCol, SEG ScrnBuf(1))
END
'=============================================================
ProcessError: '...check ErrorCode; exit if an error occurs
'=============================================================
IF ErrorCode < -1 THEN
'ErrorCodes: 0 Okay, and screen is NOT a bright background screen
' -1 Okay, and screen IS a bright background screen
'
' -999 Screen library NOT found
' -99 ScrnName not in library
' -66 Memory allocation error: Can't allocate screen buffer
' -88 Error reading disk (shouldn't happen, but who knows)
'
CLS
PRINT " Sorry, I have to end.":Print
Print " Error "; ErrorCode; "occurred displaying screen from "; LibName$;
If Instr(LibName$,".") = 0 then print ".PSL"
ky$ = INPUT$(1)
END
END IF
RETURN