Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Line Continuation Macros Continue Line \ ^!{ENTER} ErrorMode(@OFF) gwvRestoreClip = ClipGet() ErrorMode(@CANCEL) If !IsDefined(gwvLineLength) Then gwvLineLength = 0 gwvLastLineLength = gwvLineLength gwvContChar = Num2Char(182) wCopyLine() gwvLineLength = gwvLineLength + StrLen(ClipGet()) If gwvLineLength<=255 ClipPut(gwvContChar) wPaste() If wGetChar()!='' wSelEnd() wCut() EndIf wHome() While wGetChar()==" " || wGetChar() == @TAB wRight() EndWhile gwvCol = wGetColNo() If gwvLastLineLength!=0 Then gwvLineLength = gwvLineLength-gwvCol wEnd() wNewLine() If wGetColNo()!=gwvCol Then wInsString(StrFill(" ", gwvCol-wGetColNo())) If wGetColNo()!=gwvCol Then wGotoCol(gwvCol) EndIf EndIf If ClipGet()!=gwvContChar Then wPaste() wEnd() Else Beep Display(2, 'Line too long', 'Line greater than 255 characters') gwvLineLength = gwvLineLength - StrLen(ClipGet()) EndIf wStatusMsg('Wrapped line length = %gwvLineLength%') If gwvRestoreClip <> '' Then ClipPut(gwvRestoreClip) Drop(gwvCol, gwvContChar, gwvLastLineLength, gwvRestoreClip) ;------------------------------------------------------------------------------------------ Continue (Wrap) Lines \ ^W ErrorMode(@OFF) gwvRestoreClip = ClipGet() ErrorMode(@CANCEL) If !IsDefined(gwvTabSize) Then gwvTabSize = 3 If !wGetSelstate() gwvLineNo = wGetLineNo() gwvCol = wGetColNo() wInsString(@TAB) gwvTabSize = wGetColNo()-gwvCol wUndo() wHome() wInsString('MeuzyWeuWuzHere') wNewLine() wSelectAll() EndIf wCopy() gwvSelect = StrReplace(ClipGet(), @TAB, StrFill(' ', gwvTabSize)) If StrIndexNC(gwvSelect, StrCat(Num2Char(182), @CRLF), 1, @FWDSCAN) Message('Cannot Continue', 'Unwrap this file before applying automatic line continuation.') Goto CANCEL EndIf gwvDone = StrLen(gwvSelect) gwvBin = BinaryAlloc(gwvDone) BinaryPokeStr(gwvBin, 0, gwvSelect) gwvPixels = WinMetrics(0) Select 1 Case gwvPixels>=1024 gwvWrap = 119 Break Case gwvPixels>=800 gwvWrap = 89 Break Case gwvPixels>=640 gwvWrap = 71 Break EndSelect gwvTtlLines = wLineCount() gwvBout = BinaryAlloc(gwvTtlLines*gwvWrap*2) ; Need a bigger buffer to hold the wrapped text. gwvLineCnt = 0 If gwvTtlLines>100 Then wStatusMsg('Wrapped %gwvLineCnt% of %gwvTtlLines%') gwvStr = StrCat(Num2Char(182), @CRLF) gwvStart = 0 While gwvStart=gwvDone Then Break gwvPtr2 = BinaryIndexEx(gwvBin, gwvPtr1, @CRLF, @FWDSCAN, @TRUE) If !(gwvLineCnt mod 100) Then wStatusMsg('Wrapped %gwvLineCnt% of %gwvTtlLines%') EndWhile BinaryCopy(gwvBout, BinaryEodGet(gwvBout), gwvBin, gwvStart, gwvPtr1-gwvStart) If gwvPtr2==-1 || gwvPtr1>=gwvDone If gwvPtr1 '' Then ClipPut(gwvRestoreClip) Drop(gwvBin, gwvBout, gwvChunk, gwvCol, gwvDone, gwvLineCnt, gwvLineNo, gwvLn) Drop(gwvPixels, gwvPokeStr, gwvPtr1, gwvPtr2, gwvRestoreClip, gwvSelect) Drop(gwvStart, gwvStr, gwvTabSize, gwvTabStr, gwvTtlLines, gwvWrap) Drop(gwvWrapping, gwvWrapPtr) gwvLineLength = 0 wStatusMsg('Wrapped line length = %gwvLineLength%') ;------------------------------------------------------------------------------------------ Dis-Continue (Unwrap) Lines \ ^!W ErrorMode(@OFF) gwvRestoreClip = ClipGet() ErrorMode(@CANCEL) If !wGetSelstate() gwvLineNo = wGetLineNo() wSelectAll() EndIf wCopy() gwvClip = ClipGet() gwvStr = StrCat(Num2Char(182), @CRLF) If !StrIndexNC(gwvClip, gwvStr, @TRUE, @FWDSCAN) Then Goto Discontinue gwvTtlLines = wLineCount() gwvLineCnt = 0 If gwvTtlLines>100 Then wStatusMsg('Wrapped %gwvLineCnt% of %gwvTtlLines%') gwvBufSize = StrLen(gwvClip) gwvBin = BinaryAlloc(gwvBufSize) gwvBout = BinaryAlloc(gwvBufSize) gwvStart = 0 BinaryPokeStr(gwvBin, 0, gwvClip) gwvPtr = BinaryIndexEx(gwvBin, gwvStart, gwvStr, @FWDSCAN, @TRUE) While gwvPtr!=-1 gwvEnd = gwvPtr gwvLineCnt = gwvLineCnt + BinaryStrCnt(gwvBin, gwvStart, gwvEnd, @CRLF) If !(gwvLineCnt mod 100) Then wStatusMsg('Wrapped %gwvLineCnt% of %gwvTtlLines%') BinaryCopy(gwvBout, BinaryEodGet(gwvBout), gwvBin, gwvStart, gwvEnd-gwvStart) GoSub GetNextBlk While gwvWrapped gwvLineCnt = gwvLineCnt+1 If !(gwvLineCnt mod 100) Then wStatusMsg('Wrapped %gwvLineCnt% of %gwvTtlLines%') gwvPokeStr = BinaryPeekStr(gwvBin, gwvStart, gwvEnd-gwvStart) gwvPtr = 1 While StrSub(gwvPokeStr, gwvPtr, 1)==' ' || StrSub(gwvPokeStr, gwvPtr, 1)==@TAB gwvPtr = gwvPtr+1 EndWhile BinaryPokeStr(gwvBout, BinaryEodGet(gwvBout), StrSub(gwvPokeStr, gwvPtr, -1)) GoSub GetNextBlk EndWhile EndWhile BinaryClipPut(gwvBout, 1) BinaryFree(gwvBin) BinaryFree(gwvBout) wPaste() :DisContinue If IsDefined(gwvLineNo) wHome() wGotoLine(gwvLineNo) EndIf If gwvRestoreClip <> '' Then ClipPut(gwvRestoreClip) Drop(gwvBin, gwvBout, gwvBufSize, gwvClip, gwvEnd, gwvLineCnt) Drop(gwvLineNo, gwvPokeStr, gwvPtr, gwvRestoreClip, gwvStart, gwvStr) Drop(gwvTtlLines, gwvWrapped) gwvLineLength = 0 wStatusMsg('Wrapped line length = %gwvLineLength%') Exit :GetNextBlk ; What's up doc? If gwvEnd==gwvPtr gwvStart = gwvEnd+3 gwvWrapped = @TRUE Else gwvStart = gwvEnd gwvWrapped = @FALSE EndIf gwvPtr = -1 If gwvStart gwvPtr gwvEnd = gwvPtr EndIf Return
Article ID: W16710
File Created: 2005:02:18:12:21:56
Last Updated: 2005:02:18:12:21:56