Dart Tcp, Daemon, Udp Controls
DartStrings Collection
Members 
Description
Collection of strings. The DartStrings Object is used as a supporting formatting object for several PowerTCP objects and controls.
Remarks

The DartStrings Object adds some useful enhancements for string manipulation. It is most commonly used in PowerTCP as a formatting object that can easily carry out some basic manipulations, but it can also be used for other purposes. The Add and Clear methods are fast, taking linear (O(n)) time based on the number of strings (n = # of strings), as does the All property. The Delimiter method takes constant time, so any overhead related to it can usually be ignored. This performance and functionality enables some useful operations. For example, by combining the Delimiter property, Add method and All property, a rapid find/replace of any string to any string can be carried out on large files. Additionally, Dartstrings provides this capability for wide characters, so that these manipulations can be done in many different languages, not just ASCII.

This example VB find/replace code shows the power of the Dartstrings (and Dartstream). It took 500 milliseconds to replace spaces with carriage return/line feeds in a 1.12MB file of email addresses (reading from in, writing to out), including the time required by file I/O. This is about 50 times as fast as Word and Notepad, and can be done with arbitrary strings by changing the delimiter values used.

Example
Option Explicit

Private Sub Command1_Click()
	On Error GoTo OnError
	Command1.Enabled = False
	Dim Stream As New DartStream
	Stream.FileMode = createExisting
	Stream.FileName = App.Path + "\in.txt"
	Dim Strings As New DartStrings
	Strings.Delimiter = Space(1)
	Strings.Add Stream.ReadString
	Dim Stream2 As New DartStream
	Stream2.FileMode = createAlways
	Stream2.FileName = App.Path + "\out.txt"
	Strings.Delimiter = vbCrLf
	Stream2.Write Strings.All
	GoTo Done
OnError:
	Debug.Print "ERROR #" + CStr(Err.Number) + ": " + Err.Description
Done:
	Command1.Enabled = True
End Sub
See Also

DartStrings Members


Documentation Version 1.9.3.0
© 2020 Dart Communications. All Rights Reserved.
Send comments on this topic