This is a very simple procedure for the QL which ensures that words are not truncated at the end of a window….that is, it provides a word-wrap.
It does this without needing to specify the window size or a character size because it uses the “!” print delimiter.
8000 REMark FITWORD. A.Pritchard
8010 REMark Procedure to word wrap
8020 REMark any length of text to any
8030 REMark window width in any mode.
8040 REMark Parameters : channel text
8050 :
8060 DEFine PROCedure fitword(c,a$)
8070 LOCal i,ll,z,b$
8080 ll=LEN(a$)
8090 IF ll=0 THEN RETurn
8100 i=1
8110 REPeat fword
8120 z=" " INSTR a$(i TO ll)
8130 IF z=0 THEN
8140 b$=a$(i TO ll)
8150 z=ll-i
8160 ELSE
8170 b$=a$(i TO i+z-2)
8180 END IF
8190 i=i+z
8200 PRINT#c, !b$!
8210 IF i>=ll THEN
8220 EXIT fword
8230 END IF
8240 END REPeat fword
8250 END DEFine
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.