display variable in textbox?

Hello,

I want to display a variable that is calculated from another variable (PulsePeriod (from dialogue)-> Frequency) in the textbox of my graphs.

But the textbox function does not display variables

dyntext: Textbox ... \{var} does not work
printf puts it in the history.

Many thanks!

I'm guessing that the variable you want to display is a local variable in a function that makes the textbox. Local variables can't be used in dynamic text, because they must be evaluated any time the textbox is re-drawn. Since local variables don't exist after the function finishes, they aren't available later when the textbox needs to be re-drawn.

Your options are:

1. use static text in the textbox. Something like

String tboxText = "The value of something is "+num2str(var)
Textbox ... tboxText


2. Make var a global variable.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thanks a lot. It worked with the first method. I just entered num2str behind the textbox command:

TextBox/C/N=text0/F=0/E=2 "\\f01 nA3; Laser [Hz]:" + num2str (fre) + "[Hz]; Pulseduration: " + num2str (dur) + "[ms]"

titania wrote:
Thanks a lot. It worked with the first method. I just entered num2str behind the textbox command:

TextBox/C/N=text0/F=0/E=2 "\\f01 nA3; Laser [Hz]:" + num2str (fre) + "[Hz]; Pulseduration: " + num2str (dur) + "[ms]"


Alternatively ...
string theText
sprintf theText, "\\f01 nA3; Laser [Hz]: %g [Hz]; Pulseduration: %g [ms]", fre, dur
TextBox/C/N=text0/F=0/E=2 theText


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville