Hi,
If I have a series of static text components on a 2D panel.
Can I progmatically work through these items and change the text value?
(I know I could just update each box individually via a component call but I might have 30+ text boxes and it get a bit long winded)
I think... given Components
text1
text2
text3
I can build a string value, which indexes through these component Handle names,
calling the resulting string from within a 'built-in function'
for static text on a 2D panel, should I be using component|property|setvalue ?
handle: text1
property: text
value: "NewText"
new appraoch mean lots of learning and lots of questions!
Changing a components text via buit-in functions.
-
- Posts: 229
- http://meble-kuchenne.info.pl
- Joined: Sun Dec 20, 2020 6:06 pm
- Has thanked: 92 times
- Been thanked: 58 times
-
- Matrix Staff
- Posts: 1558
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 214 times
- Been thanked: 362 times
Re: Changing a components text via buit-in functions.
Yes - use that SetValue built-in function. The first parameter is a "handle" to a component, but you can also pass the name of the component as a string (and this string can be a literal string or a string variable).
Re: Changing a components text via buit-in functions.
Hi,
Simple example attached but cant get it working as expected... I think I am naming something incorrectly. I've checked capitalisation.
any pointers appreciated. J.
Simple example attached but cant get it working as expected... I think I am naming something incorrectly. I've checked capitalisation.
any pointers appreciated. J.
-
- Matrix Staff
- Posts: 1954
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 510 times
- Been thanked: 700 times
Re: Changing a components text via buit-in functions.
Hello,
Here you go this should work better now and shows a few different ways to do things.
You can see the property variable name by selecting the property and the name is shown at the bottom of the property window, it is the variable you need to reference and so in this case the variable is "sText".
Here you go this should work better now and shows a few different ways to do things.
You can see the property variable name by selecting the property and the name is shown at the bottom of the property window, it is the variable you need to reference and so in this case the variable is "sText".
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Changing a components text via buit-in functions.
Thanks, thats helped lots. 
a)
But can I programically manipulate a handle name? I guess I can NOT create a handle of the same name as that which already exists, however....
I would like to be able to feed a built-in-function with a series of sequential handle names.
Is there a way to progmatically insert 'text1', text2, text3 etc into built-in-function that requires a handle parameter.
with a normal string I could do a loop and just add a character to the root name.
MyString = MyString + "1"
b) I never before paid attention to that lowest section of the panel showing the "properties of a property" - Great info.
c) Handles have their own variable type but can be created as you would add a normal variable. setting to "Object handle"
I see there is also a Built-in-function that also allows you to create a handle.

a)
But can I programically manipulate a handle name? I guess I can NOT create a handle of the same name as that which already exists, however....
I would like to be able to feed a built-in-function with a series of sequential handle names.
Is there a way to progmatically insert 'text1', text2, text3 etc into built-in-function that requires a handle parameter.
with a normal string I could do a loop and just add a character to the root name.
MyString = MyString + "1"
b) I never before paid attention to that lowest section of the panel showing the "properties of a property" - Great info.
c) Handles have their own variable type but can be created as you would add a normal variable. setting to "Object handle"
I see there is also a Built-in-function that also allows you to create a handle.
-
- Matrix Staff
- Posts: 1558
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 214 times
- Been thanked: 362 times
Re: Changing a components text via buit-in functions.
a) You can have something like "MyString = "text" + ToString$(index)" where 'index' is an integer variable that you increment each time.
c) You can pass a string instead of a handle to that function. The function internally converts a string to a handle for you.
c) You can pass a string instead of a handle to that function. The function internally converts a string to a handle for you.
Re: Changing a components text via buit-in functions.
Thanks Ben and Steve,
I've got a better understanding of that now.
I've smashed together an improved rough example showing the various techniques discussed, it might help someone else. J.
I've got a better understanding of that now.
I've smashed together an improved rough example showing the various techniques discussed, it might help someone else. J.