Delay code evaluation

Hi

I am running automatically some code on startup and in that code I want to delay the evaluation of some lines (not the execution). Consider this code

this.preProcessor = {|code| code.replace("whatever", "'yeah!'.postln") };
whatever()

If you run the first line and then after you run the second, there is no error and you get “yeah” in the post window. However, if you now recompile the lang (to clear the preprocessor) and then run both lines together there is an error because whatever() does not exist yet when the second line is evaluated.

Anyone knows how to make this work as I need?

thanks

enrike

I would put the code that should be pre-processed into a separate file, and then:

this.preProcessor = { |code| ... my stuff ... };
"/path/to/the-file.scd".load;

You could also write "a string with all the code".interpret, but you would have to escape quotes and backslashes, which is a bother. I think the separate file would be better.

hjh

great thanks! I did not think about .load I am going to try that