DECLARE FUNCTION MyArrayGJoin$ (SeparatorI AS STRING)
DECLARE SUB MyArrayGREDIMPRESERVE (NewDimI AS INTEGER)

   '----- RedimMultiple3_TEST
   REDIM SHARED MyArrayG$(0)


   MyArrayGREDIMPRESERVE -1
   PRINT MyArrayGJoin$(";"); "<== "; LBOUND(MyArrayG$); ".."; UBOUND(MyArrayG$)

   MyArrayGREDIMPRESERVE 0
   MyArrayG$(0) = "000"
   PRINT MyArrayGJoin$(";"); "<== "; LBOUND(MyArrayG$); ".."; UBOUND(MyArrayG$)

   MyArrayGREDIMPRESERVE 1
   MyArrayG$(1) = "111"
   PRINT MyArrayGJoin$(";"); "<== "; LBOUND(MyArrayG$); ".."; UBOUND(MyArrayG$)

   MyArrayGREDIMPRESERVE 2
   MyArrayG$(2) = "222"
   PRINT MyArrayGJoin$(";"); "<== "; LBOUND(MyArrayG$); ".."; UBOUND(MyArrayG$)

   MyArrayGREDIMPRESERVE 1
   PRINT MyArrayGJoin$(";"); "<== "; LBOUND(MyArrayG$); ".."; UBOUND(MyArrayG$)

   MyArrayGREDIMPRESERVE 0
   PRINT MyArrayGJoin$(";"); "<== "; LBOUND(MyArrayG$); ".."; UBOUND(MyArrayG$)

   MyArrayGREDIMPRESERVE -1
   PRINT MyArrayGJoin$(";"); "<== "; LBOUND(MyArrayG$); ".."; UBOUND(MyArrayG$)

FUNCTION MyArrayGJoin$ (SeparatorI AS STRING)
   DIM ResultL AS STRING
   DIM iL AS INTEGER

   IF UBOUND(MyArrayG$) = 0 THEN
      IF MyArrayG$(0) = "~Empty~" THEN
         MyArrayGJoin$ = ""
         EXIT FUNCTION
      END IF
   END IF

   ResultL = ""

   '----- LOOP , Concat items
   FOR iL = 0 TO UBOUND(MyArrayG$)
      IF iL > 0 THEN ResultL = ResultL + SeparatorI
      ResultL = ResultL + MyArrayG$(iL)
   NEXT

   MyArrayGJoin$ = ResultL
END FUNCTION

SUB MyArrayGREDIMPRESERVE (NewUBoundI AS INTEGER)
   REDIM SAVEArrayL$(0)
   DIM iL AS INTEGER

   DIM FlagL AS INTEGER

   FlagL = 1

   IF NewUBoundI = -1 THEN
      REDIM MyArrayG$(0)
      MyArrayG$(0) = "~Empty~"
      EXIT SUB
   END IF

   '----- Save current array values
   IF NewUBoundI >= 0 THEN
      IF NewUBoundI < UBOUND(MyArrayG$) THEN
         REDIM SAVEArrayL$(NewUBoundI)
      ELSE
         REDIM SAVEArrayL$(UBOUND(MyArrayG$))
      END IF
      FOR iL = 0 TO UBOUND(SAVEArrayL$)
         SAVEArrayL$(iL) = MyArrayG$(iL)
      NEXT
   END IF

   REDIM MyArrayG$(NewUBoundI)

   IF FlagL = 1 THEN
      REDIM MyArrayG$(NewUBoundI + 1)
      REDIM MyArrayG$(NewUBoundI)
   END IF

   '----- Restore previously saved values
   IF (NewUBoundI >= 0) THEN
      FOR iL = 0 TO UBOUND(SAVEArrayL$)
         MyArrayG$(iL) = SAVEArrayL$(iL)
      NEXT
   END IF
END SUB
