|
Post by nikosp on Jan 13, 2024 7:21:56 GMT -5
I wander if it is possible to define an Array name in similar way like for the filenames. I mean to have a string-variable as the name of an Array.
I need that to avoid creating files (temporary or not) and so avoid write/read to the HDD in order to sort data based on a characteristic. Example
I have the following data: 2024,1,2,3,4,5... 2023,1,3,5,7... 2022,2,4,6,8,.... 2021,maria,john,mike,.... each with more than 10 elements. ... ...
If I want to process those with arrays I have to predefine those Arrays but I would like to dynamically define them with a name matching the 1st element.
Ideally I mean the command DIM blabla$ (1000) perceive the blabla$ as a variable and pick it's content for the Array's name and not actually use the string "blabla$" as the Array name.
any ideas?
|
|
|
Post by Brandon Parker on Jan 13, 2024 8:19:40 GMT -5
Hello, nikosp, and welcome to the Liberty BASIC community forum!! Unfortunately, LB does not allow the instantiation of an array's name to be dynamically based on a variable of any kind. Trust me, I wished upon many a star years ago that it were possible, but alas, it is not. There are many possibilities open to you, but I am partial to using an array library that I created and have been maintaining/updating for about 14 years now. The library can be used by itself or used with an application I created (using Liberty BASIC) called the Import Architect. If you are interested, feel free to pop over to the LB Import Architect Forum and check it out. The tool in no way attempts to compete with LB itself; it is an attempt to enhance LB and generate 100% LB code to help users perform advanced/complex tasks more easily. You can also describe what you want to do in more detail here and we can mock up a solution for you. {:0) Brandon Parker
|
|
|
Post by nikosp on Jan 13, 2024 8:27:22 GMT -5
thanks for the quick response. well, I am planning now to overcome the situation with just one Array creation and feed each element of it with a whole line of the data I have. then word$ command has a lot to do... plus some conventions are needed in the input data. thanks again/NikosP
|
|
|
Post by Marco Kurvers on Jan 13, 2024 8:28:08 GMT -5
Do you mean to use an another variabele to use the blabla$ array? That's possible. You can use diffent names for the array, even by passing the name as a parameter in a subroutine or function.
With the EVAL() function, you can use an another variabele that have the blabla$ array. But this can only to get the element. It's not possible to assign a value to the variabele.
dim blabla$(1000)
blabla$(50) = "Test"
print GetValue$("blabla", 50)
function GetValue$(arrayName$, element)
GetValue$ = eval$(arrayName$ + "$(element)")
end function
Maybe you mean something else.
With this example, you can get the content of an array with different names.
|
|
|
Post by Marco Kurvers on Jan 13, 2024 8:30:34 GMT -5
For this example, Brandon have more in the Import Architect with the same effect.
|
|