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

Possibly Related Threads…
Thread Author Replies Views Last Post
Star Suggestion for new REPLACE$() function zaadstra 3 261 01-26-2026, 05:11 PM
Last Post: grymmjack
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,225 12-19-2025, 12:51 PM
Last Post: Heimdall
  Is there a menu function? Mad Axeman 17 1,090 12-17-2025, 04:43 AM
Last Post: SMcNeill
  Sub not Reconizing Dim as String pmackay 18 1,476 10-16-2025, 03:32 PM
Last Post: pmackay
  getting the number of dimensions in an array on the fly? madscijr 7 743 09-16-2025, 12:34 AM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)