Reading value of custom UI elements from In-App script

Is it possible to read the value of a custom UI element from an In-App script? I am testing some Modbus devices and I would like the ability to change the value of some of the Modbus data that the script will send based on values from the UI.

Currently, custom UI (forms, toolbars, etc.) can only be created from full-fledged plugins, not from in-app scripts. That's because in-app scripts are volatile by nature; they are supposed to be edited/run/stopped many times by a user -- creating UI elements every time a script is started could produce undesired results.

That said, we are still experimenting with this, and some limited level of support for UI from in-app scripts will most likely appear in the upcoming release.

However, it is POSSIBLE to pass user-defined values to your in-app scrips -- you can do that using the transmit pane (either text or binary, whichever works better in your case):

void main() {
	// read input from the transmit pane

	std.Buffer data;
	getTransmitData(&data);

	// modify data before transmission

	data.insert(0, '\x02');
	data.append("\x0d\x0a");

	// off it goes!

	transmit(data.m_p, data.m_size);
}

98a83f30-80ad-46f1-95a5-ea1f3c677b1c-image.png

Hope this works for you!

Thank you for the response. That is helpful and it should work as a way to achieve what I'm looking to do. What I didn't make clear in my question though, was that I plan to create the UI element from a plugin. I would like read the plugin created UI control from an In App Script. Is that possible? I would think it is but for whatever reason I can't find documentation or an example on how to do so.

No, creating a dedicated plugin just for UI won't cut it, unfortunately.

All plugins (and the in-app scripts) run in isolated runtime environments; directly calling an object (be it a UI element or an IO object such as a socket) created in one runtime from another runtime is not possible. As such, plugins and in-app scripts can only access the UI they make themselves.

However, as I said earlier, In-App scripts will soon be able to add UI elements to conveniently fine-tune their parameters.

In the meantime, you can use the transmit pane to pass external parameters to your In-App scripts.