Block comment and uncomment code
Keywords: Block comment and uncomment code
Question:
I want to select text and have it commented out.
How can I accomplish this with WinBatch Studio ?
Answer:
Here is a WinBatch code block commenting script for use in WinBatch Studio's
configurable context menu. Clicking the right mouse button anywhere
within an open file will bring up the context menu.
To make changes to the context menu, open the WSPOPUP.MNU
file with File/Open, or access it from the context menu itself.
Right click in the file, from the context menu dialog box select
More / How do I? / Customize this menu.
functions to comment and uncomment blocks
';|' is used as comment char instead of a single ';' to distinguish it from
other uses.
the trick is to place a ';|' in front of the block, then replace all CRLF's with
CRLF+';|' except the one eventually at the end of the block
_Block Comment \ ^!C
WedCut()
cmt = ';|'
rpstr = strCat(@CRLF,cmt)
size = BinaryClipGet(0,1)
bb1 = BinaryAlloc(size)
BinaryClipGet(bb1,1)
bb2 = BinaryAlloc(size+100)
nb = BinaryPokeStr(bb2,0,cmt)
nn = BinaryCopy(bb2,nb,bb1,0,size-1)
BinaryReplace(bb2,@CRLF, rpstr, @TRUE)
eod = BinaryEodGet(bb2)
nn = BinaryCopy(bb2,eod,bb1,size-1,1)
BinaryClipPut(bb2,1)
BinaryFree(bb1)
BinaryFree(bb2)
WedPaste()
Block Uncomment \ ^!V
WedCut()
cmt = ';|'
size = BinaryClipGet(0,1)
bb1 = BinaryAlloc(size)
BinaryClipGet(bb1,1)
BinaryReplace(bb1,cmt,'', @TRUE)
BinaryClipPut(bb1,1)
BinaryFree(bb1)
WedPaste()
Article ID: W14753
Filename: Block comment and uncomment code.txt