comments desired in r.mapcalc

David Houlder david at dart
Wed Jun 22 13:15:13 EDT 1994


Steffen...
> 
> I am developing some long sequences in r.mapcalc.
> I am preparing separate files with r.mapcalc language instructions
> and wondered if there is an undocumented method 
> to place a comment into an r.mapcalc input file, for example, 
> do_it_to_it.mapcalc
> 
> 
> Does anyone have any clever ideas?


Well here's what springs to mind. Its cleverness is disputable.
** I have not tried it. Its just an idea ***

Embellish r.mapcalc with cpp, the C preprocessor and use it to strip out
C-style comments (Use /* to start a comment, */ to end): This is how
the unix command xrdb deals with comments, I think. Something like...
----------------
#!/bin/sh
#	r.cppmapcalc - allow C-style comments in mapcalc
if [ -n "$1" ] ; then
	# args on cmd line. Use plain r.mapcalc
	r.mapcalc $*
else
	# no cmd line args, reading input from stdin
	/usr/lib/cpp -P -undef | r.mapcalc
fi
-----------------
...might work (on SunOS anyway). You need the -P on cpp to stop it producing
line numbering info.

***But...
	I am not very familiar with mapcalc. If /* or */ are valid operators
	or sequences in mapcalc, then you will have problems.
	
	Similarly, if a line with # in column 1 is valid, cpp will think
	you are trying to do #define, and things will go awry.


> Perhaps a comment provision could be added to plans for future releases.
Indeed.



David Houlder			        Phone:	+61 6 249 4613
Geography Department	       	    (In Aust.:	(06) 249 4613)
The Australian National University	  Fax:	+61 6 249 3770
--------------------------------------------------------------



More information about the grass-user mailing list