albertmaathuis Posted August 19, 2012 Posted August 19, 2012 Hi there, I'm using the print udf and i wonder if it is possible to print a long line of text using line wrapping (that is the correct word I think) e.g. í'm having a $text wich contains 500 characters or more including points, commas and so on, but no carrige return or linefeed characters. What can I Use to print this line of text on a A4 printer and be sure the text is broken by the space and not in the middel of a word. perhaps it's been asked before, but I cann't find it in the topics.
Moderators Melba23 Posted August 19, 2012 Moderators Posted August 19, 2012 albertmaathuis,You might like to look at my StringSize UDF (the link is in my sig) which as well as returning the size of the text also returns the text itself with the wrapping @CRLF inserts. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
PhoenixXL Posted August 19, 2012 Posted August 19, 2012 (edited) This may help ;$sSplitIndex : the Number from where the Space Split would be Started Func _CRFromSpace($sString,$sSplitIndex=-1) If $sSplitIndex=-1 Then Return StringReplace($sString,' ',@CR) Local $nString=StringSplit($sString,' ',1) If @error Then Return SetError(1,@error,-1) Local $nLen=0 For $i=1 To $nString[0] $nLen+=StringLen($nString[$i])+1 If $nLen>$sSplitIndex Then Return StringReplace($sString,$nLen,@CR) EndIf Next $nLen-=1 Return SetError(2,$nLen,-1) EndFunc Local $aRet=_CRFromSpace('Hello There My Name is Anthony Gonsalvis',17) ConsoleWrite($aRet&@CR) Edited August 19, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
albertmaathuis Posted August 19, 2012 Author Posted August 19, 2012 Hello Melba23, Thanks, it might help. But when I download the zip file it gives an error. Something wrong with the zipper? Hello PhoenixXXL, Also thanks, I will try your solution and see what happens.
Moderators Melba23 Posted August 19, 2012 Moderators Posted August 19, 2012 albertmaathuis, I have just tested and it downloads fine for me. Perhaps try copy and paste from the forum post. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
albertmaathuis Posted August 20, 2012 Author Posted August 20, 2012 (edited) Hi, I'm going to use the solution from PhoenixXL. Working on a 64 bit server might give me problems with the dll's used in M23 program. I made a slight difference in the code, because i want it to brake the string before the last word. In that case I'm sure that my printer doesn't print outside its margins. Thanks for the help; below is the code i'm going to use. Global $previousspace,$newtext,$maxwidth $text="Visit Vinsobres in the Drôme Provençale.The large weekly markets of Nyons and Vaison la Romaine can provide you with delicious local products. For the wine lovers, there are excellent wines. The red Vinsobres is classified as the first vintage of the Côtes du Rhône in the Drôme Provençale. On foot, by bike or by car, you can explore the many cultural and historic sites or enjoy the sun and the peace on the edge of the swimming pool." $len=StringLen($text) $maxwidth=50; This is the maximum width of the new text. Do $aRet=_CRFromSpace($text,$maxwidth) $newtext=$newtext&@CRLF&StringLeft($text,$previousspace) $len=StringLen($text) $text=StringRight($text,$len-$previousspace) until $len<$maxwidth msgbox(0,"output",$newtext) Func _CRFromSpace($sString,$sSplitIndex=-1) If $sSplitIndex=-1 Then Return StringReplace($sString,' ',@CR) Local $nString=StringSplit($sString,' ',1) If @error Then Return SetError(1,@error,-1) Local $nLen=0 For $i=1 To $nString[0]; het aantal brokken van de string $nLen+=StringLen($nString[$i])+1; nlen is de teller van de spaties, de 1e spatie staat op 4, daarna op 9 If $nLen>$sSplitIndex Then; splitindex is dat getal waarNA de string wordt afgebroken. Return StringReplace($sString,$previousspace,@CR); de string wordt nu nooit langer dan de opgegeven waarde Else $previousspace=$nLen EndIf Next $nLen-=1 Return SetError(2,$nLen,-1) EndFunc Edited August 20, 2012 by Melba23 Added code tags
Moderators Melba23 Posted August 20, 2012 Moderators Posted August 20, 2012 albertmaathuis,Working on a 64 bit server might give me problems with the dll's used in M23 programNo-one has ever reported any problem with the UDF when used with an x64 OS - please let me know if you do. And when you post code in future, please use Code tags - put [autoit] before and [/autoit] after your posted code. I have done it for you above. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now