diff --git a/ARR/ARR_BYTE.BAS b/ARR/ARR_BYTE.BAS index 6ed98e9..af7dd2f 100644 --- a/ARR/ARR_BYTE.BAS +++ b/ARR/ARR_BYTE.BAS @@ -818,3 +818,37 @@ SUB ARR_BYTE.quicksort(arr%%(), start%, finish%, order%) CALL ARR_BYTE.quicksort(arr%%(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param _BYTE ARRAY source_arr%%() array to combine +' @param _BYTE ARRAY dest_arr%%() array to store combined result +' +SUB ARR_BYTE.union(source_arr%%(), dest_arr%%()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr%%) + s_ub& = UBOUND(source_arr%%) + d_lb& = LBOUND(dest_arr%%) + d_ub& = UBOUND(dest_arr%%) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _BYTE + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr%%(n&) = source_arr%%(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_DBL.BAS b/ARR/ARR_DBL.BAS index 7ff60e8..30ef452 100644 --- a/ARR/ARR_DBL.BAS +++ b/ARR/ARR_DBL.BAS @@ -818,3 +818,37 @@ SUB ARR_DBL.quicksort(arr#(), start%, finish%, order%) CALL ARR_DBL.quicksort(arr#(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param DOUBLE ARRAY source_arr#() array to combine +' @param DOUBLE ARRAY dest_arr#() array to store combined result +' +SUB ARR_DBL.union(source_arr#(), dest_arr#()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr#) + s_ub& = UBOUND(source_arr#) + d_lb& = LBOUND(dest_arr#) + d_ub& = UBOUND(dest_arr#) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS DOUBLE + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr#(n&) = source_arr#(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_FLT.BAS b/ARR/ARR_FLT.BAS index be42619..89000cb 100644 --- a/ARR/ARR_FLT.BAS +++ b/ARR/ARR_FLT.BAS @@ -818,3 +818,37 @@ SUB ARR_FLT.quicksort(arr##(), start%, finish%, order%) CALL ARR_FLT.quicksort(arr##(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param _FLOAT ARRAY source_arr##() array to combine +' @param _FLOAT ARRAY dest_arr##() array to store combined result +' +SUB ARR_FLT.union(source_arr##(), dest_arr##()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr##) + s_ub& = UBOUND(source_arr##) + d_lb& = LBOUND(dest_arr##) + d_ub& = UBOUND(dest_arr##) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _FLOAT + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr##(n&) = source_arr##(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_INT.BAS b/ARR/ARR_INT.BAS index 39b6af1..50859c3 100644 --- a/ARR/ARR_INT.BAS +++ b/ARR/ARR_INT.BAS @@ -818,3 +818,37 @@ SUB ARR_INT.quicksort(arr%(), start%, finish%, order%) CALL ARR_INT.quicksort(arr%(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param INTEGER ARRAY source_arr%() array to combine +' @param INTEGER ARRAY dest_arr%() array to store combined result +' +SUB ARR_INT.union(source_arr%(), dest_arr%()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr%) + s_ub& = UBOUND(source_arr%) + d_lb& = LBOUND(dest_arr%) + d_ub& = UBOUND(dest_arr%) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS INTEGER + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr%(n&) = source_arr%(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_INT64.BAS b/ARR/ARR_INT64.BAS index e4b3508..ca5f05a 100644 --- a/ARR/ARR_INT64.BAS +++ b/ARR/ARR_INT64.BAS @@ -818,3 +818,37 @@ SUB ARR_INT64.quicksort(arr&&(), start%, finish%, order%) CALL ARR_INT64.quicksort(arr&&(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param _INTEGER64 ARRAY source_arr&&() array to combine +' @param _INTEGER64 ARRAY dest_arr&&() array to store combined result +' +SUB ARR_INT64.union(source_arr&&(), dest_arr&&()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr&&) + s_ub& = UBOUND(source_arr&&) + d_lb& = LBOUND(dest_arr&&) + d_ub& = UBOUND(dest_arr&&) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _INTEGER64 + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr&&(n&) = source_arr&&(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_LONG.BAS b/ARR/ARR_LONG.BAS index 49cface..e33baaa 100644 --- a/ARR/ARR_LONG.BAS +++ b/ARR/ARR_LONG.BAS @@ -818,3 +818,37 @@ SUB ARR_LONG.quicksort(arr&(), start%, finish%, order%) CALL ARR_LONG.quicksort(arr&(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param LONG ARRAY source_arr&() array to combine +' @param LONG ARRAY dest_arr&() array to store combined result +' +SUB ARR_LONG.union(source_arr&(), dest_arr&()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr&) + s_ub& = UBOUND(source_arr&) + d_lb& = LBOUND(dest_arr&) + d_ub& = UBOUND(dest_arr&) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS LONG + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr&(n&) = source_arr&(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_SNG.BAS b/ARR/ARR_SNG.BAS index 6e837e3..b8de88b 100644 --- a/ARR/ARR_SNG.BAS +++ b/ARR/ARR_SNG.BAS @@ -818,3 +818,37 @@ SUB ARR_SNG.quicksort(arr!(), start%, finish%, order%) CALL ARR_SNG.quicksort(arr!(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param SINGLE ARRAY source_arr!() array to combine +' @param SINGLE ARRAY dest_arr!() array to store combined result +' +SUB ARR_SNG.union(source_arr!(), dest_arr!()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr!) + s_ub& = UBOUND(source_arr!) + d_lb& = LBOUND(dest_arr!) + d_ub& = UBOUND(dest_arr!) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS SINGLE + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr!(n&) = source_arr!(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_STR.BAS b/ARR/ARR_STR.BAS index d948cdb..f90593e 100644 --- a/ARR/ARR_STR.BAS +++ b/ARR/ARR_STR.BAS @@ -623,3 +623,36 @@ SUB ARR_STR.quicksort(arr$(), start%, finish%, order%) CALL ARR_STR.quicksort(arr$(), pivot% + 1, finish%, order%) END IF END SUB + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param STRING ARRAY source_arr$() array to combine +' @param STRING ARRAY dest_arr$() array to store combined result +' +SUB ARR_STR.union(source_arr$(), dest_arr$()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr$) + s_ub& = UBOUND(source_arr$) + d_lb& = LBOUND(dest_arr$) + d_ub& = UBOUND(dest_arr$) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS STRING + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr$(n&) = source_arr$(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_TEMPLATE.BAS b/ARR/ARR_TEMPLATE.BAS index 2fc8432..a1b2a60 100644 --- a/ARR/ARR_TEMPLATE.BAS +++ b/ARR/ARR_TEMPLATE.BAS @@ -818,3 +818,37 @@ SUB ARR_{UT}.quicksort(arr{SY}(), start%, finish%, order%) CALL ARR_{UT}.quicksort(arr{SY}(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param {Q} ARRAY source_arr{SY}() array to combine +' @param {Q} ARRAY dest_arr{SY}() array to store combined result +' +SUB ARR_{UT}.union(source_arr{SY}(), dest_arr{SY}()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr{SY}) + s_ub& = UBOUND(source_arr{SY}) + d_lb& = LBOUND(dest_arr{SY}) + d_ub& = UBOUND(dest_arr{SY}) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS {Q} + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr{SY}(n&) = source_arr{SY}(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_UBYTE.BAS b/ARR/ARR_UBYTE.BAS index 9b6c0bd..bb588ec 100644 --- a/ARR/ARR_UBYTE.BAS +++ b/ARR/ARR_UBYTE.BAS @@ -818,3 +818,37 @@ SUB ARR_UBYTE.quicksort(arr~%%(), start%, finish%, order%) CALL ARR_UBYTE.quicksort(arr~%%(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param _UNSIGNED _BYTE ARRAY source_arr~%%() array to combine +' @param _UNSIGNED _BYTE ARRAY dest_arr~%%() array to store combined result +' +SUB ARR_UBYTE.union(source_arr~%%(), dest_arr~%%()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr~%%) + s_ub& = UBOUND(source_arr~%%) + d_lb& = LBOUND(dest_arr~%%) + d_ub& = UBOUND(dest_arr~%%) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _UNSIGNED _BYTE + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr~%%(n&) = source_arr~%%(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_UINT.BAS b/ARR/ARR_UINT.BAS index a3a3627..b85041b 100644 --- a/ARR/ARR_UINT.BAS +++ b/ARR/ARR_UINT.BAS @@ -818,3 +818,37 @@ SUB ARR_UINT.quicksort(arr~%(), start%, finish%, order%) CALL ARR_UINT.quicksort(arr~%(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param _UNSIGNED INTEGER ARRAY source_arr~%() array to combine +' @param _UNSIGNED INTEGER ARRAY dest_arr~%() array to store combined result +' +SUB ARR_UINT.union(source_arr~%(), dest_arr~%()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr~%) + s_ub& = UBOUND(source_arr~%) + d_lb& = LBOUND(dest_arr~%) + d_ub& = UBOUND(dest_arr~%) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _UNSIGNED INTEGER + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr~%(n&) = source_arr~%(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_UINT64.BAS b/ARR/ARR_UINT64.BAS index 597335f..7bcd651 100644 --- a/ARR/ARR_UINT64.BAS +++ b/ARR/ARR_UINT64.BAS @@ -818,3 +818,37 @@ SUB ARR_UINT64.quicksort(arr~&&(), start%, finish%, order%) CALL ARR_UINT64.quicksort(arr~&&(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param _UNSIGNED _INTEGER64 ARRAY source_arr~&&() array to combine +' @param _UNSIGNED _INTEGER64 ARRAY dest_arr~&&() array to store combined result +' +SUB ARR_UINT64.union(source_arr~&&(), dest_arr~&&()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr~&&) + s_ub& = UBOUND(source_arr~&&) + d_lb& = LBOUND(dest_arr~&&) + d_ub& = UBOUND(dest_arr~&&) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _UNSIGNED _INTEGER64 + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr~&&(n&) = source_arr~&&(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/ARR_ULONG.BAS b/ARR/ARR_ULONG.BAS index a75a678..19d749e 100644 --- a/ARR/ARR_ULONG.BAS +++ b/ARR/ARR_ULONG.BAS @@ -818,3 +818,37 @@ SUB ARR_ULONG.quicksort(arr~&(), start%, finish%, order%) CALL ARR_ULONG.quicksort(arr~&(), pivot% + 1, finish%, order%) END IF END SUB + + + +'' +' Combine two arrays - requires both array indexes are serial with no gaps +' +' @param _UNSIGNED LONG ARRAY source_arr~&() array to combine +' @param _UNSIGNED LONG ARRAY dest_arr~&() array to store combined result +' +SUB ARR_ULONG.union(source_arr~&(), dest_arr~&()) + 's = source, d = dest, n = new + 'lb = lower bounds, ub = upper bounds + 't = total elements + DIM AS LONG s_ub, s_lb, s_t + DIM AS LONG d_ub, d_lb, d_t + DIM AS LONG n_lb, n_ub, n_t + DIM AS LONG i, n + + s_lb& = LBOUND(source_arr~&) + s_ub& = UBOUND(source_arr~&) + d_lb& = LBOUND(dest_arr~&) + d_ub& = UBOUND(dest_arr~&) + s_t& = (s_ub& - s_lb&) + d_t& = (d_ub& - d_lb&) + n_t& = s_t& + d_t& + n_lb& = d_lb& + n_ub& = d_ub& + s_t& + 1 + + REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _UNSIGNED LONG + FOR i& = s_lb& TO s_ub& + n& = d_ub& + 1 + i& - s_lb& + dest_arr~&(n&) = source_arr~&(i&) + NEXT i& +END SUB \ No newline at end of file diff --git a/ARR/README.md b/ARR/README.md index 3eb0cb4..0fbdafe 100644 --- a/ARR/README.md +++ b/ARR/README.md @@ -78,6 +78,7 @@ A bunch of very handy stuff for arrays spanning all QB64 types. | `.between` | Return elements between a start and end index in an array | | `.sort` | Sort elements of an array in ascending order | | `.rsort` | Sort elements of an array in desscending order | +| `.union` | Combine two arrays - requires both array indexes are serial with no gaps | ### SUBS AND FUNCTIONS FOR STRING TYPE: | SUB / FUNCTION | NOTES | @@ -112,9 +113,9 @@ A bunch of very handy stuff for arrays spanning all QB64 types. | `.between` | Return elements between a start and end index in an array | | `.sort` | Sort elements of an array in ascending order | | `.rsort` | Sort elements of an array in desscending order | +| `.union` | Combine two arrays - requires both array indexes are serial with no gaps | ### TO DO -- [ ] .union - [ ] .intersection - [ ] .difference \ No newline at end of file diff --git a/ARR/TEST-ARR_BYTE.BAS.bas b/ARR/TEST-ARR_BYTE.BAS.bas new file mode 100644 index 0000000..b9251ee --- /dev/null +++ b/ARR/TEST-ARR_BYTE.BAS.bas @@ -0,0 +1,36 @@ + +OPTION _EXPLICIT +'$DYNAMIC + +'$INCLUDE:'include/QB64_GJ_LIB/_GJ_LIB.BI' + +$CONSOLE:ONLY +_CONSOLE ON + +DIM arr1(1 TO 5) AS _BYTE +DIM arr2(6 TO 10) AS _BYTE +DIM arr3(11 TO 20) AS _BYTE + +DIM i AS LONG + +FOR i& = LBOUND(arr1%%) TO UBOUND(arr1%%) + arr1%%(i&) = i& +NEXT i& + +FOR i& = LBOUND(arr2%%) TO UBOUND(arr2%%) + arr2%%(i&) = i& +NEXT i& + +FOR i& = LBOUND(arr3%%) TO UBOUND(arr3%%) + arr3%%(i&) = i& +NEXT i& + +PRINT DUMP.byte_array$(arr1%%(), "arr1%%()") +PRINT DUMP.byte_array$(arr2%%(), "arr2%%()") +PRINT DUMP.byte_array$(arr3%%(), "arr3%%()") +CALL ARR_BYTE.union(arr2%%(), arr1%%()) +CALL ARR_BYTE.union(arr3%%(), arr1%%()) +PRINT DUMP.byte_array$(arr1%%(), "arr1%%() (post union) ") +SYSTEM + +'$INCLUDE:'include/QB64_GJ_LIB/_GJ_LIB.BM' diff --git a/ARR/TEST-ARR_STR.BAS.bas b/ARR/TEST-ARR_STR.BAS.bas new file mode 100644 index 0000000..87eaab7 --- /dev/null +++ b/ARR/TEST-ARR_STR.BAS.bas @@ -0,0 +1,36 @@ + +OPTION _EXPLICIT +'$DYNAMIC + +'$INCLUDE:'include/QB64_GJ_LIB/_GJ_LIB.BI' + +$CONSOLE:ONLY +_CONSOLE ON + +DIM arr1(1 TO 5) AS STRING +DIM arr2(6 TO 10) AS STRING +DIM arr3(11 TO 20) AS STRING + +DIM i AS LONG + +FOR i& = LBOUND(arr1$) TO UBOUND(arr1$) + arr1$(i&) = _TRIM$(STR$(i&)) +NEXT i& + +FOR i& = LBOUND(arr2$) TO UBOUND(arr2$) + arr2$(i&) = _TRIM$(STR$(i&)) +NEXT i& + +FOR i& = LBOUND(arr3$) TO UBOUND(arr3$) + arr3$(i&) = _TRIM$(STR$(i&)) +NEXT i& + +PRINT DUMP.string_array$(arr1$(), "arr1$()") +PRINT DUMP.string_array$(arr2$(), "arr2$()") +PRINT DUMP.string_array$(arr3$(), "arr3$()") +CALL ARR_STR.union(arr2$(), arr1$()) +CALL ARR_STR.union(arr3$(), arr1$()) +PRINT DUMP.string_array$(arr1$(), "arr1$() (post union) ") +SYSTEM + +'$INCLUDE:'include/QB64_GJ_LIB/_GJ_LIB.BM' diff --git a/ARR/generate.sh b/ARR/generate.sh index 1f648b1..c0e272c 100755 --- a/ARR/generate.sh +++ b/ARR/generate.sh @@ -3,7 +3,7 @@ # generate was used on MacOS - so gnu-sed is needed on MacOS: # brew install gnu-sed # on linux, just replace $SED with sed -SED=gsed +SED=sed TYPES=( BYTE diff --git a/_GJ_LIB_COMMON.BI b/_GJ_LIB_COMMON.BI index 0cfa86d..ff943e3 100644 --- a/_GJ_LIB_COMMON.BI +++ b/_GJ_LIB_COMMON.BI @@ -13,10 +13,12 @@ $IF FALSE = UNDEFINED AND TRUE = UNDEFINED THEN $END IF $IF SLASH = UNDEFINED THEN - $IF WIN AND SLASH THEN - CONST SLASH$ = "\" - $ELSE + $IF MAC THEN CONST SLASH$ = "/" + $ELSEIF LINUX THEN + CONST SLASH$ = "/" + $ELSEIF WIN THEN + CONST SLASH$ = "\" $END IF $END IF