View previous topic :: View next topic |
Author |
Message |
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Nov 19, 2002 1:50 pm Post subject: String "wordwrap" for List and/or Multi-line Edit. |
|
|
Example to insert CR (carriage return) and LF (line feed) in a
string for "word wrapping" to a list and a multi-line edit box.
Adjust %%maxlength to the width (number of chars) you want.
__________________________________________________________________________________________________________________________
Code: |
rem -- VDS3 and VDS4 compatible --
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Test Program,-1,0,300,200
DIALOG ADD,LIST,L1,5,5,290,95
DIALOG ADD,EDIT,E1,105,5,290,90,,,MULTI
DIALOG SHOW
%s = "In LCC-Win32 you can turn off the underscores through an option if you are using LCC-Win32's Editor (wedit)."
%%maxlength = 30
%%length = 1
%x = 1
REPEAT
if @greater(%%length, %%maxlength)
%%length = 1
rem -- Go back to nearest space --
if @not(@equal(@substr(%s, %x), " "))
REPEAT
%x = @pred(%x)
UNTIL @equal(@substr(%s, %x), " ")@equal(%x, 0)
end
if @equal(%x, 0)
INFO "Error with wordwrap routine..."@tab()
%x = @len(%s)
end
%s = @strdel(%s, %x)
%s = @strins(%s, %x, @chr(13)@chr(10))
%x = @succ(%x)
end
%%length = @succ(%%length)
%x = @succ(%x)
UNTIL @greater(%x, @len(%s))
LIST ASSIGN, L1, %s
DIALOG SET, E1, %s
:EVLOOP
WAIT EVENT
goto @event()
:CLOSE
EXIT
|
EDIT - Added code to exit loops if error occurs while trying to
find the nearest space backward.
EDIT - Added Edit box to example.
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Last edited by Mac on Tue Nov 19, 2002 5:14 pm; edited 2 times in total |
|
Back to top |
|
|
MarkTrubo Contributor
Joined: 27 May 2001 Posts: 148 Location: Long Island, NY
|
Posted: Tue Nov 19, 2002 2:30 pm Post subject: |
|
|
Thanks Mac -- that will do the trick -- you are the solution master!!! |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Nov 19, 2002 2:35 pm Post subject: |
|
|
Thanks Mark,
I think there is (was?) a similiar example somewhere
written by someone else. I just couldn't find it...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Nov 19, 2002 4:57 pm Post subject: |
|
|
Added a multi-line edit box to the example.
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
MarkTrubo Contributor
Joined: 27 May 2001 Posts: 148 Location: Long Island, NY
|
Posted: Fri Apr 18, 2003 9:34 pm Post subject: |
|
|
Question about this old wordwrap post...
I am using Mac's example in a program, but when I change the %%maxlength to be 55 for my needs, something wierd happens. The thing I'm loading into be wrapped is a file that I load into a list then assign into your variable %s with %s = @text(1). The 1st paragraph chops up fine, but the second does not. Here is the text from the file I'm loading into list 1:
Thanks for your interest! I have attached some info and look forward to speaking with you soon. If you have any questions, please feel free to call me at 800-735-5631 -- or check out our web site at www.mainstrike.com.
Hope all is well and we look forward to doing business with you. Have a great day!
Regards,
[FNAME]
Any ideas? Thank you! --Mark |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Feb 16, 2004 9:51 pm Post subject: |
|
|
I emailed Mark this fix a while back - sorry it didn't get posted
sooner. It demonstrates both a list and an editbox.
____________________________________________________________________________________________________________________________________________________________________________________________________________________
Code: |
rem -- VDS3 and VDS4 compatible --
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Test Program,-1,0,500,400
DIALOG ADD,STYLE,S1,Courier New
DIALOG ADD,LIST,L1,0,0,500,200,,S1
DIALOG ADD,EDIT,E1,200,0,500,200,,,MULTI,SCROLL,S1
DIALOG SHOW
LIST CREATE, 1
LIST ADD, 1, "In LCC-Win32 you can turn off the underscores through an option if you are using LCC-Win32's Editor (wedit)."
LIST ADD, 1, ""
LIST ADD, 1, "Thanks for your interest! I have attached some info and look forward to speaking with you soon. If you have any questions, please feel free to call me at xxx-xxx-xxxx..."
LIST ADD, 1, ""
LIST ADD, 1, "Hope all is well and we look forward to doing business with you. Have a great day!"
LIST ADD, 1, ""
LIST ADD, 1, "Regards,"
LIST ADD, 1, ""
LIST ADD, 1, "[FNAME]"
%s = @text(1)
%%maxlength = 55
%%length = 1
%x = 1
REPEAT
if @equal(@substr(%s, %x), @chr(13))@equal(@substr(%s, %x), @chr(10))
%%length = 1
end
if @greater(%%length, %%maxlength)
%%length = 1
rem -- Go back to nearest space --
if @not(@equal(@substr(%s, %x), " "))
REPEAT
%x = @pred(%x)
UNTIL @equal(%x, 0)@equal(@substr(%s, %x), " ")
end
if @equal(%x, 0)
INFO "Error with wordwrap routine..."@tab()
%x = @len(%s)
end
%s = @strdel(%s, %x)
%s = @strins(%s, %x, @chr(13)@chr(10))
%x = @succ(%x)
end
%%length = @succ(%%length)
%x = @succ(%x)
UNTIL @greater(%x, @len(%s))
LIST ASSIGN, L1, %s
DIALOG SET, E1, %s
:EVLOOP
WAIT EVENT
goto @event()
:CLOSE
EXIT
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Feb 17, 2004 6:32 am Post subject: |
|
|
I think you should've waited a couple of months more with this reply then you would have made the question's
anniversary
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Feb 17, 2004 10:28 am Post subject: |
|
|
LOL Dread - I didn't realize it had been that long
since Mark emailed me about it...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|