Page 1 of 1

Using Built In Function and Handles to Set values of Variables

Posted: Wed Jun 01, 2022 9:52 am
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. :)

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

Posted: Wed Jun 01, 2022 9:58 am
by mnfisher
I would investigate the use of an array - you can then use a loop to set static text or whatever.

Martin

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

Posted: Wed Jun 01, 2022 9:59 am
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!)

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

Posted: Wed Jun 01, 2022 10:08 am
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.

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

Posted: Wed Jun 01, 2022 10:50 am
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.

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

Posted: Wed Jun 01, 2022 10:53 am
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.

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

Posted: Wed Jun 01, 2022 10:58 am
by mnfisher
A simple example....

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

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

Posted: Wed Jun 01, 2022 11:10 am
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! :)