SUB WordWrap (X$, Wide%, PrnRow%, PrnCol%, FGColr%, BGColr%) ' +---------------------------------------------------------------------+ ' | - S U B W o r d W r a p - | ' | | ' | Public Domain - FreeWare | ' +---------------------------------------------------------------------+ ' | Author: Donald B. "Don" Smith | ' | Email : smithdonb@earthlink.net | ' +---------------------------------------------------------------------+ ' | - ABOUT THE AUTHOR - | ' +---------------------------------------------------------------------+ ' | | ' | Hello. My name is Don Smith and I am a thirty-year retired teacher | ' | of Math/History/Spanish residing in Orange County, California. I | ' | am also a former six-year Sergeant of Marines. Who-Rah! On certain | ' | forums I am known as MarineDon. My email is: smithdonb@earthlink.net| ' +---------------------------------------------------------------------+ ' | - COPYING AND DISTIBUTING - | ' +---------------------------------------------------------------------+ ' | Since this code is public domain and freeware, anyone may freely | ' | copy and distribute it. If you use the QuickBasic code in one of | ' | your own programs, you do not have to cite my name as the author, | ' | and you may even change its name. | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | SUB WordWrap will take several lines of text and place them on | ' | screen at the row and column requested. To set this up in the | ' | main module, please do as follows. | ' | | ' | First configure your text lines, then CALL WordWrap: | ' | --------------------------------------------------- | ' | | ' | a$ = "This routine restores both the menu file and the" | ' | B$ = "the database file. Do NOT use this unless your" | ' | C$ = "database files are empty or messed up. Press " | ' | D$ = "to proceed with the Restore Routine, or press " | ' | E$ = "to abort and return to the Main Menu." | ' | F$ = "" | ' | | ' | w$ = a$ + B$ + C$ + D$ + E$ + F$ | ' | Wide% = 50 'the maximum width of the display | ' | PrnRow% = 9 'the row to place the text | ' | PrnCol% = 17 'the column to place the text | ' | | ' | CALL WordWrap(w$, Wide%, PrnRow%, PrnCol%, RestFG%, RestBG%) | ' +---------------------------------------------------------------------+ length% = LEN(X$) 'what is the length Pointer% = 1 'begin at start of string ' +-----------------------------------------------------------------+ ' | scan a block of eighty characters backwards, looking for a blank| ' | stop at the first blank, or if we reached the end of the string | ' +-----------------------------------------------------------------+ DO FOR X% = Pointer% + Wide% TO Pointer% STEP -1 IF MID$(X$, X%, 1) = " " OR X% = length% + 1 THEN ConstRow% = ConstRow% + 1 'locate left margin LOCATE PrnRow% + ConstRow%, PrnCol% PRINT MID$(X$, Pointer%, X% - Pointer%); Pointer% = X% + 1 WHILE MID$(X$, Pointer%, 1) = " " Pointer% = Pointer% + 1 'omit some blanks to next word WEND IF POS(0) > 1 THEN PRINT 'if the cursor didn't wrap next EXIT FOR 'line, done with this block END IF NEXT LOOP WHILE Pointer% < length% END SUB