'--------------------------------------------------------------------- 'SCRIPT: avu-PrintWrapper 'PROJECT: gavos.apr, avcsus 'DATE: 01-29-96 'AUTHOR: John Ganter, Sandia National Labs, jganter@sandia.gov 'DESC: wraps script lines for printing 'DESC2: In Windows printing, long lines do not wrap. They are ' printed on subsequent pages. This script wraps the lines ' after adding an optional continuation character. 'CALLED BY: avu-PrintWrapperCaller or other script 'CALL AS: av.Run("avu-PrintWrapper", scriptname) 'ACCEPTS: scriptname = name of script 'RETURNS: 'EXPECTS: printer to be configured in Print Setup 'CALLS TO: '--------------------------------------------------------------------- 'Print this test pattern to see how many characters your ' printer/driver will handle ' H-P LaserJet 4si prints to 73 characters ' ' 1 2 3 4 5 6 7 8 '2345678901234567890123456789012345678901234567890123456789012345678901234567890 ' 1 2 3 4 5 6 7 8 '2345678901234567890123456789012345678901234567890123456789012345678901234567890 '-------------------------------------------------------------------------- '*********************************** USER CONFIGURATION ******************* 'set the maximum line length numMaxLength = 73 'how to do the wrap. NL is a newline character and should not be changed ' "" will not add any 'wrap' indicator strWrapIcon = " =>" ++ NL 'if you want to save the new wrapped scripts as -Wrap, set this 'switch. This can be useful if you are going to put a script into a 'document, like a manual, where you need wrapped lines. You can even skip 'printing altogether with the boolPrint switch boolSaveWrapped = False boolPrint = True '************************************************************************** 'read script strScriptName = SELF 'strScriptName = "avu-PrintWrapperSample" sedThe = av.GetProject.FindDoc(strScriptName) strThe = sedThe.GetSource 'count characters, NL is 1 character, ASCII 10 numLengthScript = strThe.Count numLengthIcon = strWrapIcon.Count numLengthNewLine = numMaxLength - numLengthIcon 'process each character in the script. Keep count of the number 'of characters since the last ASCII 10 (newline). If this count 'exceeds numLengthNewLine, then stick in strWrapIcon and reset the 'count. strNew = "" count = 0 for each i in 0 .. numLengthScript char = strThe.Middle(i, 1) strWrapIconActual = strWrapIcon numAsc = char.AsAscii if (count > numLengthNewLine ) then 'probably time to wrap numAscNext = strThe.Middle(i, 1).AsAscii 'but look at next character if ( numAscNext = 10) then 'if next char is NL, do not bother strWrapIconActual = "" end strNew = strNew + strWrapIconActual + char count = 0 elseif (numAsc = 10) then 'newline detected strNew = strNew + char count = 0 else 'normal character strNew = strNew + char count = count + 1 end end 'MsgBox.Info(strNew,"") 'create wrapped script strNewName = strScriptName + "-Wrap" strScriptWrapped = sedThe sedScriptWrapped = SEd.MakeFromSource (strNew, strNewName) 'print the wrapped script if the user wants to 'for some reason, you have to open a window before the Script.Print request will work sedScriptWrapped.GetWin.Open if ( boolPrint ) then sedScriptWrapped.Print end 'delete wrapped script if the user does not want to save it if ( boolSaveWrapped.Not ) then av.GetProject.RemoveDoc(sedScriptWrapped) end '----end of script---------------------------------------------------