Using Built In Function and Handles to Set values of Variables

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

Using Built In Function and Handles to Set values of Variables

Post by jay_dee »

Hi I have a long series of String Variables.
Row01_C1
Row01_C2
Row01_C3
Row02_C1
Row02_C2
etc...
I am trynig to load data into these Variables based on two paramters 'RxRow' and 'RxColumn'
From previous attempts I have created a Handle variable to build the name of the destination String.

Code: Select all

handle = "Row0" + ToString$ (RxRow) + "_C" + ToString$ (RxColumn)
I am now searching for the Built-In Function I need to call to allow me to set the Handle, Property, Value for the destination string variable.

I have previously set the 'sText' property of a Staic Text but I cant see how to do the same to a simple variable?
Any pointers please. :)

mnfisher
Valued Contributor
Posts: 953
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Using Built In Function and Handles to Set values of Variables

Post by mnfisher »

I would investigate the use of an array - you can then use a loop to set static text or whatever.

Martin

Steve-Matrix
Matrix Staff
Posts: 1249
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Using Built In Function and Handles to Set values of Variables

Post by Steve-Matrix »

I suggest using a 2-dimensional array. For example, "var[5][10]" would create an array which is 5 rows by 10 columns. Just remember that accessing an array starts at zero, so the "top-left" entry in the array is "var[0][0]" and the "bottom-right" is "var[4][9]".

You can then simply use your RxRow and RxColumn to access each "cell" in the array: "var[RxRow][RxColumn]". Just make sure each of RxRow and RxColumn remain in the range of your declared array.

(Martin beat me to it!)

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: Using Built In Function and Handles to Set values of Variables

Post by jay_dee »

Hi,
I did try this approach and failed ...I'll look again now as it is certainly easier to scale rather than building a huge list of strings.

That said.. If I did want to Constuct a target variable name (as described above) ...and then load a number or string into it, can this be done?
J.

Steve-Matrix
Matrix Staff
Posts: 1249
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Using Built In Function and Handles to Set values of Variables

Post by Steve-Matrix »

I'm pretty sure it can't be done. But I have been wrong before! Arrays definitely sound more appropriate for you though.

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: Using Built In Function and Handles to Set values of Variables

Post by jay_dee »

Thanks Steve, I've nearly got a 3D String array doing most of the heavy lifting now. Once it is in a understandable state I'll push it up to get feedback on how to improve it. Thanks.

mnfisher
Valued Contributor
Posts: 953
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Using Built In Function and Handles to Set values of Variables

Post by mnfisher »

A simple example....

I probably should have used x and y instead of i and j
static.fcsx
(41.42 KiB) Downloaded 56 times
Note - I called the first statictext - statictext0 then copy and paste did the numbering for me. Saves adding 1...

jay_dee
Posts: 130
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 46 times
Been thanked: 29 times

Re: Using Built In Function and Handles to Set values of Variables

Post by jay_dee »

Thanks Martin, That is interesting and very helpful to see how more experianced people have a much cleaner approach to the solution! :)

Post Reply