Category : BASIC Source Code
Archive   : PBWRITE.ZIP
Filename : PBWDEMO2.BAS

 
Output of file : PBWDEMO2.BAS contained in archive : PBWRITE.ZIP
$IF 0

PB-WRITE Simple demo #2
2 windows on the screen

$ENDIF
$COMPILE EXE
$OPTION GOSUB ON ' This is a MUST
DECLARE SUB GetStrLoc() 'we have to declare this because we need it

%FALSE = 0
%TRUE = NOT %FALSE

' These are the parameters that you need to pass to PBWRITE

BoxTOP1% = 5 ' top of the editor window
BoxLEFT1% = 5 ' left of window
BoxBOTTOM1% = 18 ' bottom of window
BoxRIGHT1% = 55 ' right of window
TextAttribute1% = &H1F ' Color of the text (bg=1, fg=15)
BorderAttribute1% = &H70 ' Color of the border (bg=7, fg=0
Margin1% = 60 ' Right margin for word wrap

CursorRow1% = 0 ' default to 0, these contain the current -
CursorCol1% = 0 ' cursor and position within the document -
DocPointer1% = 0 ' allowing you to re-enter the subroutine -
DocOffset1% = 0 ' with the document state preserved.
' Call PBWRITE again later with these
' variables preserved, and you will appear
' inside the document exactly as you left it.

FileName1$ = "NONAME1.BAS" ' This is the default filename for LOAD/SAVE


BoxTOP2% = 10 ' top of the editor window
BoxLEFT2% = 30 ' left of window
BoxBOTTOM2% = 23 ' bottom of window
BoxRIGHT2% = 75 ' right of window
TextAttribute2% = &H4E ' Color of the text (bg=4, fg=14)
BorderAttribute2% = &H74 ' Color of the border (bg=7, fg=4)
Margin2% = 60 ' Right margin for word wrap

CursorRow2% = 0 ' default to 0, these contain the current -
CursorCol2% = 0 ' cursor and position within the document -
DocPointer2% = 0 ' allowing you to re-enter the subroutine -
DocOffset2% = 0 ' with the document state preserved.
' Call PBWRITE again later with these
' variables preserved, and you will appear
' inside the document exactly as you left it.

FileName2$ = "NONAME2.BAS" ' This is the default filename for LOAD/SAVE

' Window #1 is going to be empty. Window #2 will contain PBWRITE.DOC
OPEN "PBWRITE.DOC" FOR BINARY AS #1
GET$ #1, LOF(1),DOCUMENT2$
CLOSE #1


' save the screen and cursor position

TEMP$ = SAVESCREEN$:X%=CSRLIN:Y%=POS(0)

COLOR 15,3:CLS
PRINT " PB-Write Demo #2 - 2 windows on the screen. Press ESC to switch windows or"
PRINT " Press ALT-X to quit the program completely. PB-Write hot keys are:"
PRINT " F2-Save F3-Load F4-Print F5-Zoom."

ExitCode% = 256 ' go into the window with exitcode%=%true to just
' draw the window and exit. If this is so, the
' exitcode% will return 256 on exit.


DO

' Just call the PBWRITE subroutine. It is recursive and entirely self
' contained. You may call it as many times as you want with different
' parameters to edit different documents.

PBWRITE DOCUMENT1$,_ ' string to contain the whole document
BoxTOP1%,_ ' dimensions of the edit window
BoxLEFT1%,_ '
BoxBOTTOM1%,_ '
BoxRIGHT1%,_ '
CursorRow1%,_ ' default to 0, these contain the current -
CursorCol1%,_ ' cursor and position within the document -
DocPointer1%,_ ' allowing you to re-enter the subroutine -
DocOffset1%,_ ' with the document state preserved.
FileName1$,_ ' This is just the default name for SAVE/LOAD
TextAttribute1%,_ ' The color of the text
BorderAttribute1%,_ ' The color of the border
Margin1%,_ ' The Right Margin
ExitCode%

IF ExitCode% <> 45 AND ExitCode% <> 256 THEN ExitCode% = 0
IF ExitCode%=45 THEN EXIT LOOP

PBWRITE DOCUMENT2$,_ ' string to contain the whole document
BoxTOP2%,_ ' dimensions of the edit window
BoxLEFT2%,_ '
BoxBOTTOM2%,_ '
BoxRIGHT2%,_ '
CursorRow2%,_ ' default to 0, these contain the current -
CursorCol2%,_ ' cursor and position within the document -
DocPointer2%,_ ' allowing you to re-enter the subroutine -
DocOffset2%,_ ' with the document state preserved.
FileName2$,_ ' This is just the default name for SAVE/LOAD
TextAttribute2%,_ ' The color of the text
BorderAttribute2%,_ ' The color of the border
Margin2%,_ ' The Right Margin
ExitCode%

IF ExitCode% <> 45 THEN ExitCode%=0 ' done initializing windows. Next loop
' is for actual editing.
LOOP WHILE ExitCode%<>45

' Restore the screen and cursor position
RESTORESCREEN TEMP$:LOCATE X%, Y%, 1 ' make sure cursor is visible
END
' =========================================================================
$INCLUDE "PBWRITE.BAS"

FUNCTION YesNo% (Prompt$)
O$=SAVESCREEN$
IF LEN(Prompt$) < 15 THEN Prompt$ = SPACE$(8 - LEN(Prompt$) \ 2) + Prompt$ + SPACE$(8 - LEN(Prompt$) \ 2)
Wb% = 38 - LEN(Prompt$) \ 2
Wd% = 42 + LEN(Prompt$) \ 2
Wa% = CSRLIN
Wc% = Wa% + 3
CALL SingleBox(Wa%, Wb%, Wc%, Wd%)
LOCATE Wa% + 1, 40 - LEN(Prompt$) \ 2: PRINT Prompt$
YorN = -1
LET YorN$ = " No "
DO
LOCATE Wa% + 2, 34: PRINT YorN$
DO: A$ = INKEY$: LOOP WHILE A$ = ""
IF UCASE$(A$) = "Y" THEN YorN = -1
IF UCASE$(A$) = "N" THEN YorN = 0
IF A$ = CHR$(0) + CHR$(&H4D) THEN YorN = 0
IF A$ = CHR$(0) + CHR$(&H4B) THEN YorN = -1
IF A$ = CHR$(13) THEN EXIT LOOP
IF YorN THEN LET YorN$ = " No " ELSE LET YorN$ = " Yes "

LOOP
YesNo% = YorN
RESTORESCREEN O$
END FUNCTION



  3 Responses to “Category : BASIC Source Code
Archive   : PBWRITE.ZIP
Filename : PBWDEMO2.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/