Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing fixed length string array to function
#1
Forgive me if this is an obvious issue, but...this is the first time I recall encountering it.

While using the function that I posted at: https://qb64phoenix.com/forum/showthread.php?tid=657

I tried the following bit of code as a set up for it, from a larger subroutine:

    ...
    REDIM ss(8) AS STRING * 8
    ss(1) = "1:Ia": ss(2) = "2:Ib": ss(3) = "3:II": ss(4) = "4:III"
    ss(5) = "5:IV": ss(6) = "6:V": ss(7) = "7:VI": ss(8) = "8Big Grin" ' <<<colon D throws the smilie... dwarf stars are happy bastards.
    SELECT CASE specindex
        CASE IS > 50
            DIM m AS _MEM: m = _MEM(ss): MemSmush m, 5: _MEMFREE m 'removes 5th element by copying upper ones down over it
            REDIM _PRESERVE ss(UBOUND(ss) - 1) AS STRING * 8
            ss(0) = "1234678"
        CASE IS <= 34
            DIM m1 AS _MEM: m1 = _MEM(ss): MemSmush m1, 7: _MEMFREE m1 'removes the 7th ""    """  """
            REDIM _PRESERVE ss(UBOUND(ss) - 1) AS STRING * 8
            ss(0) = "1234568"
        CASE ELSE
            ss(0) = "12345678"
    END SELECT
    ch% = Chs_Key_Button(ss(0), "h", 540, UBOUND(ss), 50, 50, 5, scrw / 2, ss()) ' <<<This last parameter is the issue
    ...

The idea of this is to filter out certain stellar size choices that don't occur with certain spectral classes (passed by specindex), if anyone is wondering the purpose of it all. The "MemSmush" sub copies all array elements above its second parameter down over that element, and zeros out the uppermost element, saving having to iterate through the array, which is why I opted for a fixed length string array in this instance.

The IDE says 'incorrect array type passed to function on current line' and references the last one shown, i.e. 'ch% = Chs_Key_...'
I've used non-fixed length string arrays with no issues and even did so here with an earlier defined one, in lieu of ss(), which it accepted. Is there a problem passing a fixed length string array to a function? Am I just forgetting some minor syntatic etiquette or what?

I could just load a variable length array in each CASE differently with no more typed code, but it seems a rather clumsy fallback position.

Thanks for looking.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply


Messages In This Thread
Passing fixed length string array to function - by OldMoses - 08-24-2022, 11:33 PM



Users browsing this thread: 5 Guest(s)