Hello, Is it possible to define a custom section of a notebook ( think for instance to type plain text ) and pass this section to a function as an argument (and escape the double quotes). For instance:
Cell #10: this is a section of this Mathematica notebook. these “contents” will be passed to the function below.
Cell #11: CustomFunction[“this is a section of this Mathematica notebook.\nthese "contents" will be passed to the function below.”]
Where of course modifying the contest of the freeform section would change the argument of CustomFunction[]. Or is there a construct like CustomFunction[%] which would indicate the contents of the cell above? Or perhaps CustomFunction[Cell[10]] or such?
Thanks, that helps already, now can “args = {“3”, “5”};” be something like:
{"3","5"};
in a single cell, probably with a plain-text stylesheet, like if a portion of the notebook was to be considered not-to-be evaluated, but to serve as string arguments to a function?
One possible approach is to use the option CellTags for the cell containing the string arguments. In this example the arguments are in a text cell with the tag Arguments. Default stylesheet.
Your screenshot indicates that you have defined the “Arguments” cell to be an Input cell (or rather that it was made to be an Input cell when you copy/pasted it). But it needs to be defined as a Text cell. Since it is supposed to contain strings, not expressions that can be evaluated.
Cell type can be changed by selecting the cell and then rightclick:
Thank you, that’s a huge leap forward.
How can I possibly make the following just print 1 2 3 (understand that I intend to replace the Print[] function with something else when this will be finalized).
Jerome, I cannot find a simple way to automatically trig evaluation when contents of the text cell are changed. Have experimented a bit with the cell option CellEventActions together with Dynamic. But no luck.