Block comments

41 views
Skip to first unread message

Dawn Wolthuis

unread,
May 24, 2009, 8:24:39 PM5/24/09
to intersystems-mv
This is not a huge issue, but a bit of an irritant and perhaps I'm
just missing something. Before I just assume I know, I'll ask -- is
there any means of doing a block comment within mvbasic methods and
routines?

If not, is there anything in MVBASIC that would make it impossible or
more difficult than one might guess to implement a block comment, or
would it simply be too low a priority to put in an enhancement request
for such? (I'm guessing I would have to put it at the end of my wish
list since it is "just" a tool while coding, but it certainly would be
nice)

If a block comment approach, such as /* */ is not feasible, could
Studio possibly do for mvbasic what it can do with COS (ctl+/ and
ctl+shift+/) and permit us to highlight code, then quote or unquote
it?

Thanks. --dawn
--
Dawn M. Wolthuis
Take and give some delight today

Jason Warner

unread,
May 25, 2009, 1:36:12 PM5/25/09
to InterSy...@googlegroups.com
Dawn,

I'm fairly new to PICK basic/mvbasic, but I did some investigation into
this when first learning pick. It was frustrating to only have a line
level comment for me. The answer I was given is there is no definition
for a block level comment in PICK. I tend to agree that it gets tedious
and frustrating going down lines and typing * at the beginning to
comment out blocks or removing those * to uncomment blocks of code. I
would also lobby for a way in Studio to quickly comment/uncomment blocks
of code. Another nice one would be to be able to apply my format options
to a file. Both of those exist for all languages in Visual Studio and I
miss them when working in Cache's Studio.

Jason

Ed Clark

unread,
May 25, 2009, 3:13:13 PM5/25/09
to InterSy...@googlegroups.com
as a workaround, you can use $IFDEF/$ENDIF to simulate block-comments:

$IFNDEF INTERSYSTEMS
    OSOPEN "c:\boot.init"
    PRINTERR "201":@am:"no such file
    CALLC getkey(x)
$ENDIF

INTERSYSTEMS is a $DEFINEd identifier that is always defined in cache mvbasic, so the IFNDEF will always be false and the code/text in the block will not get parsed Studio will still color it as an error, but if you use some other editor (ed, jed, notepad, vi) that doesn't do error coloring, then that's not a problem.

I'm used to putting a star at the beginning of each line for block comments (when I started on mv, we had dumb terminals carved out of limestone, and ED was the only way to edit), but I use IFDEF a lot when migrating code to cache, or when I need a block of code that runs on multiple platforms (that IFNDEF block above gets ignored on cache, but will get compiled on jbase with no changes.).

Downside: $IFDEF only works in .mvb files. It does not work in mvbasic methods in classes.

fyi: Sudio's control-/ does work in .mvb source. It prefixes REM onto the marked lines. But in classes it prefixes the line with //, which is fine for object script, but no use in mvbasic.

Dawn Wolthuis

unread,
May 25, 2009, 9:43:48 PM5/25/09
to InterSy...@googlegroups.com
Thanks for the tip re $IFNDEF, Ed. We've been sticking to Studio for 

When I read the Studio doc when I started, it sounded like it might work like other editors for MV where you can highlight lines, hit some key or keys and either comment or uncomment them. I think I mentioned that it didn't work as documented, but that it would be cool if it did, so now I see the doc is changed to make clear it is only for COS methods. I should be more precise with my requests, eh?

I realize that MVBASIC doesn't have a multiline comments with /*   */ but it doesn't have OO constructs either, so... It looks like the Studio enhancement request, not high on my list (on the one hand) likely isn't logged anywhere, so if anyone else is has brownie points to spare or is in the mood to get that one into the queue, I'll second the motion.

When the MVBASIC is not in a method, then folks (other than me) are using accuterm, which has the desired feature that is missing from Studio wrt to multiline commenting and uncommenting.

Thanks.  --dawn

tomh

unread,
Jun 3, 2009, 6:00:01 AM6/3/09
to InterSystems: MV Community
FWIW, Another couple of work arounds....

HighLight the block of mvBasic code, hit ctrl-/ 2 times, hit ctrl-H
and replace all '////' with '*'.


I use Crimson Editor, in place of NotePad. It has mvbasic syntax
highlighting, and block comment / uncomment.

Copy & Paste the block into Crimson editor, comment out the code,
paste back into studio.

Doesn't really pay for small blocks though ...

Tom H

Tony G

unread,
Jun 3, 2009, 11:39:31 AM6/3/09
to InterSy...@googlegroups.com
> From: tomh
> HighLight the block of mvBasic code, hit ctrl-/ 2 times, hit
ctrl-H
> and replace all '////' with '*'.

I use PhraseExpress (PE) which allows for auto text correction,
hotkey macros, and (as the name implies) entry of phrases with
just a few keys. You can use this or similar tools to select
text and then hotkey in the workaround that Tom suggests. A
freeware version of PE is available from phraseexpress.com.

I also use AutoHotKey (popularly referred to as AHK) to do the
same thing and to provide features in products that aren't
already available, like "IntelliSense" (TM) help and other
features from an MV terminal emulator. This is also freeware.

You can also use AccuTerm wED for editing/compiling your Caché
MVBASIC code, though you don't get other benefits of Studio.

So above you have four solutions that you can have today.

I wouldn't recommend waiting but I've been working on a back
burner project for a new cross-MV, multi-language (JS+XML+BASIC)
GUI editor which has a lot of functionality that's not found
elsewhere (like code folding, regions, onscreen help, code
templates/snippets, and server-side search/open of related code).
Writing lexical/semantic parsers for MV BASIC is bad enough but
it just occurred to me that I'll need to support Caché object
syntax too. Let's call that v2+. :)

Tony Gravagno
Nebula Research and Development
TG@ remove.pleaseNebula-RnD.com
Visit PickWiki.com! Contribute!

Reply all
Reply to author
Forward
0 new messages