Skip to main content
Associate III
December 16, 2023
Solved

just send a value

  • December 16, 2023
  • 1 reply
  • 1168 views

How to simply send a value in a text or numeric zone (textArea)?

This topic has been closed for replies.
Best answer by GaetanGodart

Hello @NicoEFI ,

I suggest you follow the tutorials on our website.
In the 4th chapter of the second tutorial we talk about passing value to a text area.
Find this chapter here : Tutorial 2, chapter 4 (wildcards) 

Basically, you have to add a wildcard to your text area
I usually select "used wildcard buffer", this creates an array of character of the size mentioned (minus one for the character of end of string).
Then in your code you can overwrite this buffer with :
Unicode::snprintf(param1, param2, param3, param4);
Replace param1 with the name of your text area + "buffer", ex : myTextAreaBuffer.
Replace param2 with the name of your text area in capital + "_SIZE", ex : MYTEXTAREA_SIZE.
Replace param3 with the string you want to pass, in your case an int so "%d".
Finally, replace param4 with the variable you want to print, ex : myInt.

Edit :
Don't forget to invalidate the area you want to change.
Ex : textArea.invalidate()


Hope this helps.
Don’t hesitate to give us a feedback or give more precisions and tell us if the issue is solved! :smiling_face_with_smiling_eyes:

1 reply

GaetanGodart
GaetanGodartBest answer
Technical Moderator
December 18, 2023

Hello @NicoEFI ,

I suggest you follow the tutorials on our website.
In the 4th chapter of the second tutorial we talk about passing value to a text area.
Find this chapter here : Tutorial 2, chapter 4 (wildcards) 

Basically, you have to add a wildcard to your text area
I usually select "used wildcard buffer", this creates an array of character of the size mentioned (minus one for the character of end of string).
Then in your code you can overwrite this buffer with :
Unicode::snprintf(param1, param2, param3, param4);
Replace param1 with the name of your text area + "buffer", ex : myTextAreaBuffer.
Replace param2 with the name of your text area in capital + "_SIZE", ex : MYTEXTAREA_SIZE.
Replace param3 with the string you want to pass, in your case an int so "%d".
Finally, replace param4 with the variable you want to print, ex : myInt.

Edit :
Don't forget to invalidate the area you want to change.
Ex : textArea.invalidate()


Hope this helps.
Don’t hesitate to give us a feedback or give more precisions and tell us if the issue is solved! :smiling_face_with_smiling_eyes:

NicoEFIAuthor
Associate III
December 19, 2023

Thanks, i have tested this, it works 

//float valued = (float) value/10; //for decimal value
//Unicode::snprintfFloat(textArea1Buffer, TEXTAREA1_SIZE, "%.1f", valued);
//textArea1.invalidate();

value = value * 100;
Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%d", value);
textArea1.invalidate();