Scripting Guide > Display Trees > Construct Custom Windows > Send Messages to Constructed Displays
Publication date: 05/24/2021

## Send Messages to Constructed Displays

When you assign a constructed display to a name, that name becomes a reference to the window, which in turn owns the display boxes inside it. Using subscripts, you can then send messages to the display boxes inside the window.

For example, the following script creates an interactive sine wave graph. The script automates the interaction by sending messages to the frame box inside the window. Note the frame box assignment to tf in the middle of the script).

`amplitude = 1;`
`freq = 1;`
`phase = 0;`
`win = New Window( "Wiggle Wave",`
`	Graph Box(`
`		Frame Size( 500, 300 ),`
`		X Scale( -5, 5 ),`
`		Y Scale( -5, 5 ),`
`		Y Function( amplitude * Sine( x / freq + phase ), x );`
`		Handle(`
` `

/* current values of phase and amplitude position

the square handle.

script begins after the last comma after amplitude */

`			phase,`
`			amplitude,`
` `

/* x and y have been set to the handle’s position

but the handle doesn’t move unless the values specified

in the first two arguments are updated */

`			phase = x;`
`			amplitude = y;`
`		);`
` `

// Handle works similarly except that the y value is .5

`		Handle( freq, .5, freq = x );`
` `
`		Text( // display a text string in the graph`
`			{3, 4},`
`			"amplitude: ",`
`			Round( amplitude, 4 ), // display the current value`
`			{3, 3.5},`
`			"frequency: ",`
`			Round( freq, 4 ), // display the current value`
`			{3, 3},`
`			"phase: ",`
`			Round( phase, 4 ) // display the current value`
`		);`
`	)`
`);`
`tf = win[Frame Box( 1 )]; // get the frame box (the graph)`
`For( amplitude = -4, amplitude < 4, amplitude += .1,// animate the amplitude`
`	tf << Reshow // force the graph to update`
`);`
`amplitude = 1; // use for loops for more complex movement`
`freq = 1;`
`phase = 0;`
`For( i = 0, i < 1000, i++,`
`	amplitude += (Random Uniform() - .5);`
`	amplitude = If(`
`		amplitude > 4, 4,`
`		amplitude < -4, -4,`
`		amplitude`
`	);`
`	freq += (Random Uniform() - .5) / 20;`
`	phase += (Random Uniform() - .5) / 10;`
`	tf << Reshow;`
`	Wait( .05 );`
`);`
{"ft_lang_label":"__label__en","ft_lang_prob":0.5771189,"math_prob":0.993005,"size":1830,"snap":"2021-31-2021-39","text_gpt3_token_len":515,"char_repetition_ratio":0.15443593,"word_repetition_ratio":0.054285713,"special_character_ratio":0.33989072,"punctuation_ratio":0.2123656,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9973377,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-23T03:09:27Z\",\"WARC-Record-ID\":\"<urn:uuid:4a49d8bb-d40b-4e28-9194-2c5a38b6a138>\",\"Content-Length\":\"12277\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4e07cdd5-923c-4908-9606-4be1b5aae274>\",\"WARC-Concurrent-To\":\"<urn:uuid:abb88325-016e-4ead-a099-cdab93571553>\",\"WARC-IP-Address\":\"23.208.33.227\",\"WARC-Target-URI\":\"https://www.jmp.com/support/help/en/16.1/jmp/send-messages-to-constructed-displays.shtml\",\"WARC-Payload-Digest\":\"sha1:XT6CFGT7JDM5LDDVLSPWCI465PIBDW4A\",\"WARC-Block-Digest\":\"sha1:VEJEECIPSKI3I3PVVV4FVITJFMR7BBSF\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057416.67_warc_CC-MAIN-20210923013955-20210923043955-00403.warc.gz\"}"}