Changing a components text via buit-in functions.

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jay_dee
Posts: 229
http://meble-kuchenne.info.pl
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 92 times
Been thanked: 58 times

Changing a components text via buit-in functions.

Post by jay_dee »

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!

Steve-Matrix
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.

Post by Steve-Matrix »

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).

jay_dee
Posts: 229
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 92 times
Been thanked: 58 times

Re: Changing a components text via buit-in functions.

Post by jay_dee »

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.
Built_In_Functions_V1.fcsx
(18.25 KiB) Downloaded 628 times
J.

BenR
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.

Post by BenR »

Hello,

Here you go this should work better now and shows a few different ways to do things.

Built_In_Functions_V1.fcsx
(18.25 KiB) Downloaded 442 times

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".

Text.png
Text.png (11.08 KiB) Viewed 5309 times

jay_dee
Posts: 229
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 92 times
Been thanked: 58 times

Re: Changing a components text via buit-in functions.

Post by jay_dee »

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.

Steve-Matrix
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.

Post by Steve-Matrix »

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.

jay_dee
Posts: 229
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 92 times
Been thanked: 58 times

Re: Changing a components text via buit-in functions.

Post by jay_dee »

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.
Built_In_Function-ChangingText_V3.fcsx
(32.34 KiB) Downloaded 471 times
J.

Post Reply