Is there any example of that ?
'PRINT SPLITTER (messageBox o2 function)
indexbase 1
string src,source
string txt=nuls 100000 'buffer
string lines[100000] 'lines array
sys pt=strptr txt 'buffer base pointer
sys i.j,p 'indexes and pointer
'test data:
'==========
cr=chr(13)+chr(10)
'lc="abc"+cr
'mid (txt,1)=lc+lc+lc+lc+lc
txt = GetFile "C:\o2Basic\OxygenBasic\array1.rub"
print txt 'look this ????
'IT IS WOW !!! print already split file into lines?
'how is that possible ???
Oxygen does not use line arrays. Instead, it encodes the physical line number into the code source text, which is one large string. This ensures that the physical line number passes through several compiler stages, which have different sets of lines.
'=============
'LINE SPLITTER
'=============
indexbase 1
string lines[100000] 'static lines array
sys i.j 'indexes
'data:
'=====
'txt=getfile "s.txt"
'txt=nuls 100000
'sendMessage richedit1,WM_GETTEXT,100000, strptr txt
'
txt="11
22
33
44
55
66
77
"
'initial
'=======
'
'
b=1 'start of line
i=0 'lines array index
j=1 'char index
'
'
'splitter loop
'=============
'
do
select asc(txt,j)
case 0
if j-b>0 then
i++
lines[i]=mid(txt,b,j-b)
end if
exit do
case 10 'LF TERMINATED LINES
i++
lines[i]=mid(txt,b,j-b)
b=j+1
case 13 'CR AND CRLF TERMINATED LINES
i++
lines[i]=mid(txt,b,j-b)
if asc(txt,j+1)=10 then j++ 'SKIP LF
b=j+1
end select
j++
end do
cr=chr(13)+chr(10)
print "Lines: " i cr +
"Line 5: " lines[5] + cr +
"Last: " lines[i]
... maybe you can show internal code of ArrayfromFile() ...
i am not from yesterday..ok ;)
Are you sure you could use one?