Array Split
I've rewritten the array splitting function, and cheated by using a static array.
' Array split
' https://www.powerbasic.com/support/pbforums/showthread.php?t=17642
' Function to Split a given string to form an array
''#COMPILE EXE
''#DIM ALL
'
'% filename "ArraySplit64.exe"
'includepath "$\inc\"
'include "RTL64.inc"
#lookahead
indexbase 1
% msgbox mbox
''GLOBAL Tmp() AS STRING
GLOBAL Tmp(16000) AS STRING
FUNCTION PBMAIN() AS LONG
DIM Kount AS LONG
DIM jj AS LONG
DIM Ast AS STRING
' When there are inbetween blank spaces in a string which
' are unwanted, we use a SHRINK statement
Ast = "Hello, world, What, a, Nice, day, outside, My, Window "
ArSplit( Ast, ",",Kount )
' prints out the array contents
''OPEN "arOut.txt" FOR OUTPUT AS #3
local output as string
FOR jj = 1 TO Kount
''PRINT #3, jj, Tmp(jj)
output += str(jj)+chr(9)+tmp(jj)+chr(13,10)
NEXT jj
''CLOSE #3
putfile("ArOut.txt",output)
MSGBOX "done"
END FUNCTION
sub ArSplit( GivenSt AS STRING, Delimit$ AS STRING ,Cnt AS LONG)
local byref b as byte
@b=strptr(GivenSt)
local d as byte
d=asc(Delimit$)
local i,j,e,bg,as long
bg=1
for i=1 to len(GivenSt)+1
select b(i)
case 0,d
j+=1
tmp(j)=ltrim(rtrim(mid(GivenSt,bg,i-bg)))
bg=i+1
Cnt+=1
end select
next
end sub
'=====================================
' Split a given string to form an array
''SUB ArSplit( GivenSt AS STRING, Delimit$ ,Cnt AS LONG )
'' LOCAL Strt, i AS LONG
'' 'get rid of inbetween blanks first
'' GivenSt = TRIM$(GivenSt)
'' GivenSt = SHRINK$(GivenSt)
'' Cnt = PARSECOUNT(GivenSt, Delimit$)
'' REDIM Tmp(1 TO Cnt&)
''
'' Strt& = 1
'' FOR i& = 1 TO Cnt&
'' Tmp(I&) = TRIM$(EXTRACT$(Strt&, GivenSt, Delimit$))
'' Strt& = INSTR(Strt&, GivenSt, Delimit$) + 1
'' NEXT
''END SUB
PBMAIN()