Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array in an array
#2
Hi @NasaCow

As you know, we can't do arrays in arrays, so there is no simple solution you are missing.

You can store an array into a string using a Join$ function, just give it an array and a delimiter to separate the different values. 

It's brother is a Split Sub that takes the string and breaks it back up into an array: you give it a dynamic array name to load and tell it what the string is that contains the array and the delimiter used.

Here are the Join$ and Split routines I use:
Code: (Select All)
' note: I buggered this twice now, FOR base 1 array REDIM MyArray (1 to 1) AS ... the (1 to 1) is not same as (1) which was the Blunder!!!
'notes: REDIM the array(0) to be loaded before calling Split '<<<< IMPORTANT dynamic array and empty, can use any lbound though
'This SUB will take a given N delimited string, and delimiter$ and create an array of N+1 strings using the LBOUND of the given dynamic array to load.
'notes: the loadMeArray() needs to be dynamic string array and will not change the LBOUND of the array it is given.  rev 2019-08-27
Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
    Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
    curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
    dpos = InStr(curpos, SplitMeString, delim)
    Do Until dpos = 0
        loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
        arrpos = arrpos + 1
        If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
        curpos = dpos + LD
        dpos = InStr(curpos, SplitMeString, delim)
    Loop
    loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
    ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
End Sub

Function Join$ (arr() As String, delimiter$)
    Dim i As Long, b$
    For i = LBound(arr) To UBound(arr)
        If i = LBound(arr) Then b$ = arr(LBound(arr)) Else b$ = b$ + delimiter$ + arr(i)
    Next
    Join$ = b$
End Function

I will be surprised if you get this in one go and if your array is an UDT (User Desigined Type) it's more complicated still.

I am wondering if I went over something like this when you were last here. The Join$ and Split Routines work very well as I have done GUI and Interpreter with them!

A further complication is if you want to file all this, and why not! Then you have to use fixed strings or some fancy Binary file header.
b = b + ...
Reply


Messages In This Thread
Array in an array - by NasaCow - 02-15-2023, 12:44 AM
RE: Array in an array - by bplus - 02-15-2023, 01:55 AM
RE: Array in an array - by OldMoses - 02-15-2023, 02:43 AM
RE: Array in an array - by NasaCow - 02-15-2023, 03:17 AM
RE: Array in an array - by OldMoses - 02-15-2023, 11:02 AM
RE: Array in an array - by mnrvovrfc - 02-15-2023, 03:53 AM
RE: Array in an array - by SMcNeill - 02-15-2023, 12:59 PM
RE: Array in an array - by bplus - 02-15-2023, 05:31 PM
RE: Array in an array - by bplus - 02-16-2023, 04:25 PM
RE: Array in an array - by NasaCow - 02-17-2023, 12:03 AM
RE: Array in an array - by SpriggsySpriggs - 02-17-2023, 05:43 PM
RE: Array in an array - by Kernelpanic - 02-18-2023, 03:49 PM
RE: Array in an array - by TempodiBasic - 03-11-2023, 02:59 AM
RE: Array in an array - by bplus - 02-17-2023, 06:32 PM
RE: Array in an array - by TerryRitchie - 02-17-2023, 09:12 PM
RE: Array in an array - by SMcNeill - 02-17-2023, 11:42 PM
RE: Array in an array - by madscijr - 02-28-2023, 07:14 AM
RE: Array in an array - by mnrvovrfc - 02-17-2023, 10:57 PM
RE: Array in an array - by TerryRitchie - 02-18-2023, 02:24 AM
RE: Array in an array - by AtomicSlaughter - 02-18-2023, 09:39 AM
RE: Array in an array - by bplus - 02-18-2023, 12:47 PM
RE: Array in an array - by TempodiBasic - 02-18-2023, 09:25 PM
RE: Array in an array - by TempodiBasic - 02-18-2023, 09:41 PM
RE: Array in an array - by TempodiBasic - 02-18-2023, 10:01 PM
RE: Array in an array - by Kernelpanic - 02-18-2023, 11:07 PM
RE: Array in an array - by TempodiBasic - 02-19-2023, 01:46 AM
RE: Array in an array - by TempodiBasic - 02-21-2023, 12:19 AM
RE: Array in an array - by bplus - 02-21-2023, 01:07 AM
RE: Array in an array - by mnrvovrfc - 02-21-2023, 05:13 AM
RE: Array in an array - by TempodiBasic - 02-21-2023, 02:26 PM
RE: Array in an array - by mnrvovrfc - 02-21-2023, 02:54 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 01:18 AM
RE: Array in an array - by TempodiBasic - 02-21-2023, 02:37 PM
RE: Array in an array - by bplus - 02-21-2023, 02:16 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 06:04 PM
RE: Array in an array - by bplus - 02-21-2023, 06:26 PM
RE: Array in an array - by mnrvovrfc - 02-21-2023, 10:24 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 05:59 PM
RE: Array in an array - by bplus - 02-21-2023, 06:33 PM
RE: Array in an array - by bplus - 02-21-2023, 06:42 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 06:45 PM
RE: Array in an array - by bplus - 02-21-2023, 06:51 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 09:19 PM
RE: Array in an array - by bplus - 02-21-2023, 11:13 PM
RE: Array in an array - by TempodiBasic - 02-22-2023, 09:32 AM
RE: Array in an array - by Kernelpanic - 02-27-2023, 07:05 PM
RE: Array in an array - by Kernelpanic - 02-28-2023, 03:33 PM
RE: Array in an array - by madscijr - 02-28-2023, 06:24 PM
RE: Array in an array - by TempodiBasic - 03-11-2023, 02:23 PM
RE: Array in an array - by Kernelpanic - 02-28-2023, 11:14 PM
RE: Array in an array - by madscijr - 03-01-2023, 02:13 AM
RE: Array in an array - by mnrvovrfc - 03-01-2023, 03:29 AM
RE: Array in an array - by bplus - 03-01-2023, 04:00 PM
RE: Array in an array - by madscijr - 03-01-2023, 05:24 PM
RE: Array in an array - by Sprezzo - 03-02-2023, 08:34 AM
RE: Array in an array - by bplus - 03-02-2023, 05:18 PM
RE: Array in an array - by mnrvovrfc - 03-02-2023, 04:26 PM
RE: Array in an array - by SpriggsySpriggs - 03-02-2023, 05:19 PM
RE: Array in an array - by bplus - 03-02-2023, 05:25 PM
RE: Array in an array - by SpriggsySpriggs - 03-02-2023, 05:26 PM
RE: Array in an array - by bplus - 03-02-2023, 05:28 PM
RE: Array in an array - by Dimster - 03-02-2023, 06:05 PM
RE: Array in an array - by bplus - 03-02-2023, 06:20 PM
RE: Array in an array - by SpriggsySpriggs - 03-02-2023, 07:12 PM
RE: Array in an array - by mnrvovrfc - 03-02-2023, 10:46 PM
RE: Array in an array - by madscijr - 03-03-2023, 12:47 AM
RE: Array in an array - by SpriggsySpriggs - 03-03-2023, 02:59 AM
RE: Array in an array - by madscijr - 03-03-2023, 04:24 AM
RE: Array in an array - by mnrvovrfc - 03-03-2023, 07:22 AM
RE: Array in an array - by mnrvovrfc - 03-03-2023, 07:11 AM
RE: Array in an array - by vince - 03-03-2023, 10:07 AM
RE: Array in an array - by SpriggsySpriggs - 03-03-2023, 01:02 PM
RE: Array in an array - by madscijr - 03-03-2023, 03:06 PM
RE: Array in an array - by vince - 03-03-2023, 03:17 PM
RE: Array in an array - by SpriggsySpriggs - 03-03-2023, 03:25 PM
RE: Array in an array - by mnrvovrfc - 03-11-2023, 06:22 PM
RE: Array in an array - by NasaCow - 03-13-2023, 03:29 AM
RE: Array in an array - by TempodiBasic - 04-02-2023, 10:14 PM
RE: Array in an array - by NasaCow - 04-06-2023, 02:37 AM
RE: Array in an array - by TempodiBasic - 04-12-2023, 10:53 AM



Users browsing this thread: 21 Guest(s)