Solved Syntax question (1 Viewer)

Edgar_

Active member
Local time
Today, 05:09
Joined
Jul 8, 2023
Messages
430
Btw, a 'phone home' strategy does not necessarily require owning a website. Free services and free tiers from paid services can store the keys and the same goes for custom key generation if that was necessary. Each alternative will have a different set of instructions to follow, but I believe it would be more secure...

Writing 16 functions to change the array values is useless, you can just use a select case.
OP keeps asking for a functional syntax and functions could do it.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 11:09
Joined
Sep 12, 2006
Messages
15,656
I don't know the answer offhand, but is there a way to redefine a series of variables, as a single contiguous array of variables, so that eg array(x,y,z) could be treated as an array of length x*y*z,or even as a single string of that length, starting at array,(0,0,0). I have used this idea in other languages where you can redefine a variable starting @the memory location of another variable.
.
(More likely x+1 * y-+1 * z+1), but I'm sure you know what I mean.

So if you declare 16 arrays(3,3,3), you can then treat this as a single array of length 16x64 or 1024. Then you can use the active array segment in the range 1 to 16 to slice this long string, without having to "get at" the variable name which gets lost at runtime.

Then you wouldn't have to use eval, you could slice the single array/string using mid type functions with simple arithmetic, which might be easier to code.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:09
Joined
Feb 19, 2002
Messages
43,275
The syntax doesn't work to reference an array. I'm going to just leave the data in a table now that it is there and get it from the table. Thanks to all of you.
 

Josef P.

Well-known member
Local time
Today, 12:09
Joined
Feb 2, 2023
Messages
826
[OT (or not)]

I have created a few variants to compare how to store data in multiple arrays or similar.

Note:
The initial situation is only similar to the question in #1.
I used classes to verify comparability with an interface.


Interface:
Code:
Public Sub Config(ByRef ContainerConfig() As Long)
' ContainerConfig = Array(n, 1 to 2)
'    ContainerConfig(n, 1) ... Container index
'    ContainerConfig(n, 2) ... Container size (1 to n)
End Sub

Public Property Get DataValue(ByVal ContainerIndex As Long, ByVal ItemIndex As Long) As String
' ContainerIndex .. Index of container
' ItemIndex .. Index of value in container
End Property

Public Property Let DataValue(ByVal ContainerIndex As Long, ByVal ItemIndex As Long, ByVal NewValue As String)
'
End Property

Characteristics of the variants:

a) ArraysDataContainer
Private Array1() As String
Private Array2() As String
Private Array3() As String

b) NestedArraysDataContainer
Private DcArray() As Variant
+
DcArray(..) = SubArray

c) DictionaryDataContainer
Private DcDict As Dictionary
+
DcDict.Add DictIndex, SubDictionary
 

Attachments

  • ArrayContainerRefactoring.zip
    29 KB · Views: 24
Last edited:

Users who are viewing this thread

Top Bottom