I am trying to define a function test that takes a string and returns 
the value of the variable the string represents. For example, if aaa = 
25, then bbb = \test "aaa" would be the same as bbb = \aaa. 

If I use the eval-string command directly, it is working fine. When I 
try to put it in a function, it comes up with the error wrong type as 
below:

\version "2.18.2"

test =
#(define-scheme-function
     (parser location raga)
     (string?)
     (format #t "Inside function raga = ~a ~%" raga)
     ((eval-string raga)))
     

abc = IamJustAText
ab = enna
ennac = parava

xyz = #(eval-string  (string-append ab "c") )

#(format #t "1) abc = ~a   xyz = ~a ~%" abc xyz)

% This prints: 1) abc = IamJustAText   xyz = parava 

par = abc

#(format #t "2) abc = ~a   xyz = ~a par = ~a ~%" abc xyz (eval-string 
par) )

% This prints ) abc = IamJustAText   xyz = parava par = IamJustAText 

xyz = \test #(string-append ab "c")

% This gives an error: 
%   document.ly:8:6: In expression ((eval-string raga)):
%   document.ly:8:6: Wrong type to apply: "parava"

#(format #t "3) xyz ~a ~%" xyz)

% This is the end of this example program



_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to