Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Thu Aug 01, 2002 3:29 am Post subject: Wordwrap |
|
|
I'll be using this program for wordwrapping my input to this forum, so that no more
hugely long lines would appear if someone would have posted a script in the same
topic, causing the browser's built-in wordwrapping functionality to fail.
I'm sure this could be useful for other purposes too. Just select the correct pixel
width and font and make sure that vdsimage.dll is available.
| Code: |
rem for VDS 4 and up only.
rem will need some modifications related to WHILE loops for VDS 3.
external vdsimage.dll
%%maxwidth = 526
%%font = Verdana
%%size = 9
%%attributes =
DIALOG CREATE,Wordwrap,-1,0,552,304
DIALOG ADD,STYLE,sStyle,%%font,%%size,%%attributes,,
DIALOG ADD,EDIT,eText,8,8,536,256,,,MULTI,sStyle
DIALOG ADD,BUTTON,bProcess,272,448,88,24,&Process
DIALOG SHOW
:evloop
wait event
goto @event()
:bProcessbutton
list create,1
list assign,1,@dlgtext(eText)
list create,2
%i = 0
%%nextline =
repeat
%%nextline = @trim(@item(1,%i))
gosub addnextline
%i = @succ(%i)
until @equal(%i,@count(1))
if %%nextline
gosub addnextline
end
dialog set,eText,@text(2)
list close,2
list close,1
goto evloop
:processline
%%nextline =
while @both(@greater(@image(textwidth,%%line,%%font,%%size,%%attributes),%%maxwidth),@greater(@pos(" ",%%line),0))
%j = @len(%%line)
repeat
%j = @pred(%j)
until @equal(@substr(%%line,%j)," ")
%%nextline = @substr(%%line,@succ(%j),@len(%%line))" "%%nextline
%%line = @strdel(%%line,%j,@len(%%line))
wend
exit
:addnextline
if %%nextline
while %%nextline
%%line = %%nextline
gosub processline
list add,2,@trim(%%line)
wend
else
list add,2,
end
exit
:close
exit
|
|
|