| Rapid-Q Documentation by William Yu (c)1999 | Appendix A: QSTRINGLIST |
|
| |
| Field | Type | R/W | Default | Support |
|
|
|
|
|
|
| Duplicates | INTEGER | RW | dupIgnore | W |
| Item | ARRAY of STRING (index starts at 0 | RW | WXG | |
| ItemCount | INTEGER | R | WXG | |
| Sorted | INTEGER | RW | False | W |
| Text | STRING | RW | WXG |
| Method | Type | Description | Params | Support |
|
|
|
|
|
|
| AddItems | SUBI | Add strings to stringlist | STRINGs, Infinite | WXG |
| AddList | SUB (List AS QStringList) | Append another stringlist | 1 | WXG |
| Build | FUNCTION Build(Start%, End%, Delim$) AS STRING | Returns a deliminated string | 3 | WXG |
| Clear | SUB | Clears entire stringlist | 0 | WXG |
| DelItems | SUBI | Delete strings by their index | Index #s, Infinite | WXG |
| Exchange | SUB (Index1%, Index2%) | Swap strings at Index1% with Index2% | 2 | WXG |
| IndexOf | FUNCTION IndexOf%(String$) | Return Index number of string | 1 | WXG |
| InsertItem | SUB (Index%, String$) | Insert string at Index%,. Index% must be within bounds.of ItemCount |
2 | WXG |
| LoadFromFile | SUB (File$) | Load text file in stringlist | 1 | WXG |
| LoadFromStream | SUB (File AS QStream) | Load file/memorystream in stringlist | 1 | W |
| Parse | FUNCTION Parse(Source$, Delim$) AS LONG | Separates strings by the Delim$ and stores each item in the list | 2 | WXG |
| SaveToFile | SUB (File$) | Saves stringlist to file | 1 | WXG |
| SaveToStream | SUB (File AS QStream) | WARNING: Saving to a MemorySteam does not work and erases the StringList!! |
1 | W |
| Sort | SUB | Sort the stringlist | 0 | WXG |
| Event | Type | Occurs when... | Params |
|
|
|
|
|
DIM StringList1 AS QStringList
DIM StringList2 AS QStringList
StringList1.AddItems "Oranges","Apples"
StringList2.AddItems "Byte","Word","Integer"
StringList1.AddList(StringList2)
StringList1.Sort
?StringList1.Text
?StringList1.Item(3)
?StringList1.IndexOf("Word")
?StringList1.IndexOf("hi")
'-------------------------------------------------------
DIM StringList AS QSTRINGLIST
StringList.Parse("James:Brown:555-3454:House",":")
PRINT StringList.Build(0,StringList.ItemCount-1,",")
'____________________________________________________________
QStringList is very fast, a lot faster than QFileStream.ReadBinStr
FUNCTION LoadString(FileName as STRING) AS string
DIM fileStr as QFileStream
result="0"
if fileStr.open (FileName,0 )=-1 then
result="-1"
result=FileStr.ReadBinStr( FileStr.size)
FileStr.Close
end if
END FUNCTION
'******************************'
$INCLUDE "RAPIDQ.INC"
'--- Declarations ---
dim SList as QStringList
'print "create string", time$
'for i =0 to 500
'ss0$=ss0$+string$(2000,"a")
'next
'print "begin to save string",time$
'SaveString(ss0$,"large01.txt")
print "begin to load string ",time$
SList.loadfromfile("large02.txt")
print "Loaded 2.. ",time$
print"len SList.text=";len(SList.text)
ss$=LoadString("large02.txt")
print "Loaded.. ",time$
print"len ss$=";len(ss$)
'------------------------
RESULT:
Loading 28 Mb txt file
loadfromfile <1sec
ReadBinStr ~11 sec
| Prev Component | Contents | Next Component |