Hello folks,
I searched a little bit, to get something like the #ifndef stuff in a
C-Header into some lily-files I include regularly.
Now I worked it out myself and I'd like to share it:
--snip--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% included from somewhere
#(if (not (defined? 'dostuff))(define-public dostuff #t))
% do something
#(if dostuff (define count 0))
#(if dostuff (set! count (+ count 1)))
#(if dostuff (define-public mystuff (list)))
#(if dostuff (display count))
#(if dostuff (display " Hello World\n"))
% set dostuff to false
#(set! dostuff #f)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% included again from somewhere
#(if (not (defined? 'dostuff))(define-public dostuff #t))
% do something
#(if dostuff (define count 0))
#(if dostuff (set! count (+ count 1)))
#(if dostuff (define-public mystuff (list)))
#(if dostuff (display count))
#(if dostuff (display " Hello World\n"))
% set dostuff to false
#(set! dostuff #f)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--snip--
In this example, "Hello World" will be displayed only once.
You need this, if you define a global function or a global list of items
like my footnote-items (http://lsr.dsi.unimi.it/LSR/Item?id=728) and
include the containing file more than once.
In fact, if you get into this situation, you also may rethink your
file-organization ...
Stay tuned and have a good day!
Jan-Peter
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user