Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$RESIZE with Word-Wrap Routine.
#5
Well crickets so far on the Linux issue and $RESIZE with _NEWIMAGE.

I like this resize code I put together. When I get some more time, I think I'll see if I can map it and assign arrays. I've made two types of WP routines. One that always writes to the drive, and another that uses arrays for each line of text. This would be a single array, which I've done in part before for parsing, but not in complete WP.

Use left and right arrow keys to squash/expand page width from the right side.
Code: (Select All)
WIDTH 160, 42
_FONT 16
_SCREENMOVE 10, 10
w = _WIDTH
DO
    _LIMIT 30
    ' Two text samples. The first has some multiple spaces. The routine will left justify but if the number of spaces equals or exceeds the page width then the whole line is left blank.
    REM x$ = "In West    Los Angeles born and raised, at    the    yacht club is where I spent most of my      days, 'til a couple of coders      who were up to no good, started making trouble in my neighborhood. I got booted off Discord and my vids wouldn't play, so I moved to the hills in the State of VA. I pulled up to the forum 'bout a week into April and I yelled to the browser save password log in later. Now I'm able to post and my speech is still free as I sit on my throne as the Prince of P.E."
    x$ = "In West Los Angeles born and raised, at the yacht club is where I spent most of my days, 'til a couple of coders who were up to no good, started making trouble in my neighborhood. I got booted off Discord and my vids wouldn't play, so I moved to the hills in the State of VA. I pulled up to the forum 'bout a week into April and I yelled to the browser save password log in later. Now I'm able to post and my speech is still free as I sit on my throne as the Prince of P.E."
    CLS
    IF w < _WIDTH - 1 THEN
        FOR i = 1 TO _HEIGHT: LOCATE i, w + 1: PRINT CHR$(179);: NEXT
    END IF
    LOCATE 1, 1
    ' ------------------------------------------------------Wrap Routine----------------------------------------------
    DO
        WHILE -1
            t$ = MID$(x$, 1, w)
            chop = 1
            IF w <> 1 THEN
                DO
                    IF LEFT$(t$, 1) = " " THEN ' Only happens with more than 1 space between characters.
                        IF LTRIM$(t$) = "" THEN EXIT DO ELSE x$ = LTRIM$(x$): EXIT WHILE
                    END IF
                    IF MID$(x$, w + 1, 1) <> " " AND LTRIM$(t$) <> "" THEN ' Now we have to chop it.
                        IF INSTR(x$, " ") > 1 AND INSTR(t$, " ") <> 0 AND LEN(x$) > w THEN
                            t$ = MID$(t$, 1, _INSTRREV(t$, " ") - 1)
                            chop = 2
                        END IF
                    ELSE
                        chop = 2
                    END IF
                    EXIT DO
                LOOP
                x$ = MID$(x$, LEN(t$) + chop)
            ELSE
                x$ = MID$(x$, LEN(t$) + 1)
            END IF
            IF LEN(t$) AND CSRLIN < _HEIGHT - 1 THEN LOCATE , ml + 1: PRINT LTRIM$(t$)
            EXIT WHILE
        WEND
    LOOP UNTIL LEN(t$) AND LEN(LTRIM$(x$)) = 0
    ------------------------------------------------------------------------------------------------------------------
    DO
        b$ = INKEY$
        IF LEN(b$) THEN
            IF b$ = CHR$(27) THEN SYSTEM
            SELECT CASE MID$(b$, 2, 1)
                CASE "K"
                    IF w > 1 THEN w = w - 1
                    EXIT DO
                CASE "M"
                    IF w < _WIDTH - 1 THEN w = w + 1
                    EXIT DO
            END SELECT
        END IF
    LOOP
LOOP

Pete
Reply


Messages In This Thread
$RESIZE with Word-Wrap Routine. - by Pete - 12-06-2022, 02:39 PM
RE: $RESIZE with Word-Wrap Routine. - by Pete - 12-06-2022, 03:36 PM
RE: $RESIZE with Word-Wrap Routine. - by Pete - 12-06-2022, 03:40 PM
RE: $RESIZE with Word-Wrap Routine. - by Pete - 12-06-2022, 10:05 PM
RE: $RESIZE with Word-Wrap Routine. - by SMcNeill - 12-06-2022, 10:32 PM
RE: $RESIZE with Word-Wrap Routine. - by Pete - 12-07-2022, 05:23 AM
RE: $RESIZE with Word-Wrap Routine. - by SMcNeill - 12-07-2022, 06:48 AM
RE: $RESIZE with Word-Wrap Routine. - by Pete - 12-07-2022, 07:49 AM
RE: $RESIZE with Word-Wrap Routine. - by Pete - 12-09-2022, 07:05 PM



Users browsing this thread: 3 Guest(s)