xref: /aoo41x/main/wizards/source/tools/Strings.xba (revision cdf0e10c)
1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2*cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Strings" script:language="StarBasic">Option Explicit
4*cdf0e10cSrcweirPublic sProductname as String
5*cdf0e10cSrcweir
6*cdf0e10cSrcweir
7*cdf0e10cSrcweir&apos; Deletes out of a String &apos;BigString&apos; all possible PartStrings, that are summed up
8*cdf0e10cSrcweir&apos; in the Array &apos;ElimArray&apos;
9*cdf0e10cSrcweirFunction ElimChar(ByVal BigString as String, ElimArray() as String)
10*cdf0e10cSrcweirDim i% ,n%
11*cdf0e10cSrcweir	For i = 0 to Ubound(ElimArray)
12*cdf0e10cSrcweir		BigString = DeleteStr(BigString,ElimArray(i)
13*cdf0e10cSrcweir	Next
14*cdf0e10cSrcweir	ElimChar = BigString
15*cdf0e10cSrcweirEnd Function
16*cdf0e10cSrcweir
17*cdf0e10cSrcweir
18*cdf0e10cSrcweir&apos; Deletes out of a String &apos;BigString&apos; a possible Partstring &apos;CompString&apos;
19*cdf0e10cSrcweirFunction DeleteStr(ByVal BigString,CompString as String) as String
20*cdf0e10cSrcweirDim i%, CompLen%, BigLen%
21*cdf0e10cSrcweir	CompLen = Len(CompString)
22*cdf0e10cSrcweir	i = 1
23*cdf0e10cSrcweir	While i &lt;&gt; 0
24*cdf0e10cSrcweir		i = Instr(i, BigString,CompString)
25*cdf0e10cSrcweir		If i &lt;&gt; 0 then
26*cdf0e10cSrcweir			BigLen = Len(BigString)
27*cdf0e10cSrcweir			BigString = Mid(BigString,1,i-1) + Mid(BigString,i+CompLen,BigLen-i+1-CompLen)
28*cdf0e10cSrcweir		End If
29*cdf0e10cSrcweir	Wend
30*cdf0e10cSrcweir	DeleteStr = BigString
31*cdf0e10cSrcweirEnd Function
32*cdf0e10cSrcweir
33*cdf0e10cSrcweir
34*cdf0e10cSrcweir&apos; Finds a PartString, that is framed by the Strings &apos;Prestring&apos; and &apos;PostString&apos;
35*cdf0e10cSrcweirFunction FindPartString(BigString, PreString, PostString as String, SearchPos as Integer) as String
36*cdf0e10cSrcweirDim StartPos%, EndPos%
37*cdf0e10cSrcweirDim BigLen%, PreLen%, PostLen%
38*cdf0e10cSrcweir	StartPos = Instr(SearchPos,BigString,PreString)
39*cdf0e10cSrcweir	If StartPos &lt;&gt; 0 Then
40*cdf0e10cSrcweir		PreLen = Len(PreString)
41*cdf0e10cSrcweir		EndPos = Instr(StartPos + PreLen,BigString,PostString)
42*cdf0e10cSrcweir		If EndPos &lt;&gt; 0 Then
43*cdf0e10cSrcweir			BigLen = Len(BigString)
44*cdf0e10cSrcweir			PostLen = Len(PostString)
45*cdf0e10cSrcweir			FindPartString = Mid(BigString,StartPos + PreLen, EndPos - (StartPos + PreLen))
46*cdf0e10cSrcweir			SearchPos = EndPos + PostLen
47*cdf0e10cSrcweir		Else
48*cdf0e10cSrcweir			Msgbox(&quot;No final tag for &apos;&quot; &amp; PreString &amp; &quot;&apos; existing&quot;, 16, GetProductName())
49*cdf0e10cSrcweir			FindPartString = &quot;&quot;
50*cdf0e10cSrcweir		End If
51*cdf0e10cSrcweir	Else
52*cdf0e10cSrcweir		FindPartString = &quot;&quot;
53*cdf0e10cSrcweir	End If
54*cdf0e10cSrcweirEnd Function
55*cdf0e10cSrcweir
56*cdf0e10cSrcweir
57*cdf0e10cSrcweir&apos; Note iCompare = 0 (Binary comparison)
58*cdf0e10cSrcweir&apos; 	   iCompare = 1 (Text comparison)
59*cdf0e10cSrcweirFunction PartStringInArray(BigArray(), SearchString as String, iCompare as Integer) as Integer
60*cdf0e10cSrcweirDim MaxIndex as Integer
61*cdf0e10cSrcweirDim i as Integer
62*cdf0e10cSrcweir	MaxIndex = Ubound(BigArray())
63*cdf0e10cSrcweir	For i = 0 To MaxIndex
64*cdf0e10cSrcweir		If Instr(1, BigArray(i), SearchString, iCompare) &lt;&gt; 0 Then
65*cdf0e10cSrcweir			PartStringInArray() = i
66*cdf0e10cSrcweir			Exit Function
67*cdf0e10cSrcweir		End If
68*cdf0e10cSrcweir	Next i
69*cdf0e10cSrcweir	PartStringInArray() = -1
70*cdf0e10cSrcweirEnd Function
71*cdf0e10cSrcweir
72*cdf0e10cSrcweir
73*cdf0e10cSrcweir&apos; Deletes the String &apos;SmallString&apos; out of the String &apos;BigString&apos;
74*cdf0e10cSrcweir&apos; in case SmallString&apos;s Position in BigString is right at the end
75*cdf0e10cSrcweirFunction RTrimStr(ByVal BigString, SmallString as String) as String
76*cdf0e10cSrcweirDim SmallLen as Integer
77*cdf0e10cSrcweirDim BigLen as Integer
78*cdf0e10cSrcweir	SmallLen = Len(SmallString)
79*cdf0e10cSrcweir	BigLen = Len(BigString)
80*cdf0e10cSrcweir	If Instr(1,BigString, SmallString) &lt;&gt; 0 Then
81*cdf0e10cSrcweir		If Mid(BigString,BigLen + 1 - SmallLen, SmallLen) = SmallString Then
82*cdf0e10cSrcweir			RTrimStr = Mid(BigString,1,BigLen - SmallLen)
83*cdf0e10cSrcweir		Else
84*cdf0e10cSrcweir			RTrimStr = BigString
85*cdf0e10cSrcweir		End If
86*cdf0e10cSrcweir	Else
87*cdf0e10cSrcweir		RTrimStr = BigString
88*cdf0e10cSrcweir	End If
89*cdf0e10cSrcweirEnd Function
90*cdf0e10cSrcweir
91*cdf0e10cSrcweir
92*cdf0e10cSrcweir&apos; Deletes the Char &apos;CompChar&apos; out of the String &apos;BigString&apos;
93*cdf0e10cSrcweir&apos; in case CompChar&apos;s Position in BigString is right at the beginning
94*cdf0e10cSrcweirFunction LTRimChar(ByVal BigString as String,CompChar as String) as String
95*cdf0e10cSrcweirDim BigLen as integer
96*cdf0e10cSrcweir	BigLen = Len(BigString)
97*cdf0e10cSrcweir	If BigLen &gt; 1 Then
98*cdf0e10cSrcweir		If Left(BigString,1) = CompChar then
99*cdf0e10cSrcweir	 		BigString = Mid(BigString,2,BigLen-1)
100*cdf0e10cSrcweir	 	End If
101*cdf0e10cSrcweir	ElseIf BigLen = 1 Then
102*cdf0e10cSrcweir	 	BigString = &quot;&quot;
103*cdf0e10cSrcweir	End If
104*cdf0e10cSrcweir	LTrimChar = BigString
105*cdf0e10cSrcweirEnd Function
106*cdf0e10cSrcweir
107*cdf0e10cSrcweir
108*cdf0e10cSrcweir&apos; Retrieves an Array out of a String.
109*cdf0e10cSrcweir&apos; The fields of the Array are separated by the parameter &apos;Separator&apos;, that is contained
110*cdf0e10cSrcweir&apos; in the Array
111*cdf0e10cSrcweir&apos; The Array MaxIndex delivers the highest Index of this Array
112*cdf0e10cSrcweirFunction ArrayOutOfString(BigString, Separator as String, Optional MaxIndex as Integer)
113*cdf0e10cSrcweirDim LocList() as String
114*cdf0e10cSrcweir	LocList=Split(BigString,Separator)
115*cdf0e10cSrcweir
116*cdf0e10cSrcweir	If not isMissing(MaxIndex) then maxIndex=ubound(LocList())
117*cdf0e10cSrcweir
118*cdf0e10cSrcweir	ArrayOutOfString=LocList
119*cdf0e10cSrcweirEnd Function
120*cdf0e10cSrcweir
121*cdf0e10cSrcweir
122*cdf0e10cSrcweir&apos; Deletes all fieldvalues in one-dimensional Array
123*cdf0e10cSrcweirSub ClearArray(BigArray)
124*cdf0e10cSrcweirDim i as integer
125*cdf0e10cSrcweir	For i = Lbound(BigArray()) to Ubound(BigArray())
126*cdf0e10cSrcweir		BigArray(i) = &quot;&quot;
127*cdf0e10cSrcweir	Next
128*cdf0e10cSrcweirEnd Sub
129*cdf0e10cSrcweir
130*cdf0e10cSrcweir
131*cdf0e10cSrcweir&apos; Deletes all fieldvalues in a multidimensional Array
132*cdf0e10cSrcweirSub ClearMultiDimArray(BigArray,DimCount as integer)
133*cdf0e10cSrcweirDim n%, m%
134*cdf0e10cSrcweir	For n = Lbound(BigArray(),1) to Ubound(BigArray(),1)
135*cdf0e10cSrcweir		For m = 0 to Dimcount - 1
136*cdf0e10cSrcweir			BigArray(n,m) = &quot;&quot;
137*cdf0e10cSrcweir		Next m
138*cdf0e10cSrcweir	Next n
139*cdf0e10cSrcweirEnd Sub
140*cdf0e10cSrcweir
141*cdf0e10cSrcweir
142*cdf0e10cSrcweir&apos; Checks if a Field (LocField) is already defined in an Array
143*cdf0e10cSrcweir&apos; Returns &apos;True&apos; or &apos;False&apos;
144*cdf0e10cSrcweirFunction FieldinArray(LocArray(), MaxIndex as integer, LocField as String) As Boolean
145*cdf0e10cSrcweirDim i as integer
146*cdf0e10cSrcweir	For i = Lbound(LocArray()) to MaxIndex
147*cdf0e10cSrcweir		If Ucase(LocArray(i)) = Ucase(LocField) Then
148*cdf0e10cSrcweir			FieldInArray = True
149*cdf0e10cSrcweir			Exit Function
150*cdf0e10cSrcweir		End if
151*cdf0e10cSrcweir	Next
152*cdf0e10cSrcweir	FieldInArray = False
153*cdf0e10cSrcweirEnd Function
154*cdf0e10cSrcweir
155*cdf0e10cSrcweir
156*cdf0e10cSrcweir&apos; Checks if a Field (LocField) is already defined in an Array
157*cdf0e10cSrcweir&apos; Returns &apos;True&apos; or &apos;False&apos;
158*cdf0e10cSrcweirFunction FieldinList(LocField, BigList()) As Boolean
159*cdf0e10cSrcweirDim i as integer
160*cdf0e10cSrcweir	For i = Lbound(BigList()) to Ubound(BigList())
161*cdf0e10cSrcweir		If LocField = BigList(i) Then
162*cdf0e10cSrcweir			FieldInList = True
163*cdf0e10cSrcweir			Exit Function
164*cdf0e10cSrcweir		End if
165*cdf0e10cSrcweir	Next
166*cdf0e10cSrcweir	FieldInList = False
167*cdf0e10cSrcweirEnd Function
168*cdf0e10cSrcweir
169*cdf0e10cSrcweir
170*cdf0e10cSrcweir&apos; Retrieves the Index of the delivered String &apos;SearchString&apos; in
171*cdf0e10cSrcweir&apos; the Array LocList()&apos;
172*cdf0e10cSrcweirFunction IndexinArray(SearchString as String, LocList()) as Integer
173*cdf0e10cSrcweirDim i as integer
174*cdf0e10cSrcweir	For i = Lbound(LocList(),1) to Ubound(LocList(),1)
175*cdf0e10cSrcweir		If Ucase(LocList(i,0)) = Ucase(SearchString) Then
176*cdf0e10cSrcweir			IndexinArray = i
177*cdf0e10cSrcweir			Exit Function
178*cdf0e10cSrcweir		End if
179*cdf0e10cSrcweir	Next
180*cdf0e10cSrcweir	IndexinArray = -1
181*cdf0e10cSrcweirEnd Function
182*cdf0e10cSrcweir
183*cdf0e10cSrcweir
184*cdf0e10cSrcweirSub MultiArrayInListbox(oDialog as Object, ListboxName as String, ValList(), iDim as Integer)
185*cdf0e10cSrcweirDim oListbox as Object
186*cdf0e10cSrcweirDim i as integer
187*cdf0e10cSrcweirDim a as Integer
188*cdf0e10cSrcweir	a = 0
189*cdf0e10cSrcweir	oListbox = oDialog.GetControl(ListboxName)
190*cdf0e10cSrcweir	oListbox.RemoveItems(0, oListbox.GetItemCount)
191*cdf0e10cSrcweir	For i = 0 to Ubound(ValList(), 1)
192*cdf0e10cSrcweir		If ValList(i) &lt;&gt; &quot;&quot; Then
193*cdf0e10cSrcweir			oListbox.AddItem(ValList(i, iDim-1), a)
194*cdf0e10cSrcweir			a = a + 1
195*cdf0e10cSrcweir		End If
196*cdf0e10cSrcweir	Next
197*cdf0e10cSrcweirEnd Sub
198*cdf0e10cSrcweir
199*cdf0e10cSrcweir
200*cdf0e10cSrcweir&apos; Searches for a String in a two-dimensional Array by querying all Searchindexex of the second dimension
201*cdf0e10cSrcweir&apos; and delivers the specific String of the ReturnIndex in the second dimension of the Searchlist()
202*cdf0e10cSrcweirFunction StringInMultiArray(SearchList(), SearchString as String, SearchIndex as Integer, ReturnIndex as Integer, Optional MaxIndex as Integer) as String
203*cdf0e10cSrcweirDim i as integer
204*cdf0e10cSrcweirDim CurFieldString as String
205*cdf0e10cSrcweir	If IsMissing(MaxIndex) Then
206*cdf0e10cSrcweir		MaxIndex = Ubound(SearchList(),1)
207*cdf0e10cSrcweir	End If
208*cdf0e10cSrcweir	For i = Lbound(SearchList()) to MaxIndex
209*cdf0e10cSrcweir		CurFieldString = SearchList(i,SearchIndex)
210*cdf0e10cSrcweir		If  Ucase(CurFieldString) = Ucase(SearchString) Then
211*cdf0e10cSrcweir			StringInMultiArray() = SearchList(i,ReturnIndex)
212*cdf0e10cSrcweir			Exit Function
213*cdf0e10cSrcweir		End if
214*cdf0e10cSrcweir	Next
215*cdf0e10cSrcweir	StringInMultiArray() = &quot;&quot;
216*cdf0e10cSrcweirEnd Function
217*cdf0e10cSrcweir
218*cdf0e10cSrcweir
219*cdf0e10cSrcweir&apos; Searches for a Value in multidimensial Array by querying all Searchindices of the passed dimension
220*cdf0e10cSrcweir&apos; and delivers the Index where it is found.
221*cdf0e10cSrcweirFunction GetIndexInMultiArray(SearchList(), SearchValue, SearchIndex as Integer) as Integer
222*cdf0e10cSrcweirDim i as integer
223*cdf0e10cSrcweirDim MaxIndex as Integer
224*cdf0e10cSrcweirDim CurFieldValue
225*cdf0e10cSrcweir	MaxIndex = Ubound(SearchList(),1)
226*cdf0e10cSrcweir	For i = Lbound(SearchList()) to MaxIndex
227*cdf0e10cSrcweir		CurFieldValue = SearchList(i,SearchIndex)
228*cdf0e10cSrcweir		If CurFieldValue = SearchValue Then
229*cdf0e10cSrcweir			GetIndexInMultiArray() = i
230*cdf0e10cSrcweir			Exit Function
231*cdf0e10cSrcweir		End if
232*cdf0e10cSrcweir	Next
233*cdf0e10cSrcweir	GetIndexInMultiArray() = -1
234*cdf0e10cSrcweirEnd Function
235*cdf0e10cSrcweir
236*cdf0e10cSrcweir
237*cdf0e10cSrcweir&apos; Searches for a Value in multidimensial Array by querying all Searchindices of the passed dimension
238*cdf0e10cSrcweir&apos; and delivers the Index where the Searchvalue is found as a part string
239*cdf0e10cSrcweirFunction GetIndexForPartStringinMultiArray(SearchList(), SearchValue, SearchIndex as Integer) as Integer
240*cdf0e10cSrcweirDim i as integer
241*cdf0e10cSrcweirDim MaxIndex as Integer
242*cdf0e10cSrcweirDim CurFieldValue
243*cdf0e10cSrcweir	MaxIndex = Ubound(SearchList(),1)
244*cdf0e10cSrcweir	For i = Lbound(SearchList()) to MaxIndex
245*cdf0e10cSrcweir		CurFieldValue = SearchList(i,SearchIndex)
246*cdf0e10cSrcweir		If Instr(CurFieldValue, SearchValue) &gt; 0 Then
247*cdf0e10cSrcweir			GetIndexForPartStringinMultiArray() = i
248*cdf0e10cSrcweir			Exit Function
249*cdf0e10cSrcweir		End if
250*cdf0e10cSrcweir	Next
251*cdf0e10cSrcweir	GetIndexForPartStringinMultiArray = -1
252*cdf0e10cSrcweirEnd Function
253*cdf0e10cSrcweir
254*cdf0e10cSrcweir
255*cdf0e10cSrcweirFunction ArrayfromMultiArray(MultiArray as String, iDim as Integer)
256*cdf0e10cSrcweirDim MaxIndex as Integer
257*cdf0e10cSrcweirDim i as Integer
258*cdf0e10cSrcweir	MaxIndex = Ubound(MultiArray())
259*cdf0e10cSrcweir	Dim ResultArray(MaxIndex) as String
260*cdf0e10cSrcweir	For i = 0 To MaxIndex
261*cdf0e10cSrcweir		ResultArray(i) = MultiArray(i,iDim)
262*cdf0e10cSrcweir	Next i
263*cdf0e10cSrcweir	ArrayfromMultiArray() = ResultArray()
264*cdf0e10cSrcweirEnd Function
265*cdf0e10cSrcweir
266*cdf0e10cSrcweir
267*cdf0e10cSrcweir&apos; Replaces the string &quot;OldReplace&quot; through the String &quot;NewReplace&quot; in the String
268*cdf0e10cSrcweir&apos; &apos;BigString&apos;
269*cdf0e10cSrcweirFunction ReplaceString(ByVal Bigstring, NewReplace, OldReplace as String)  as String
270*cdf0e10cSrcweir	ReplaceString=join(split(BigString,OldReplace),NewReplace)
271*cdf0e10cSrcweirEnd Function
272*cdf0e10cSrcweir
273*cdf0e10cSrcweir
274*cdf0e10cSrcweir&apos; Retrieves the second value for a next to &apos;SearchString&apos; in
275*cdf0e10cSrcweir&apos; a two-dimensional string-Array
276*cdf0e10cSrcweirFunction FindSecondValue(SearchString as String, TwoDimList() as String ) as String
277*cdf0e10cSrcweirDim i as Integer
278*cdf0e10cSrcweir	For i = 0 To Ubound(TwoDimList,1)
279*cdf0e10cSrcweir		If Ucase(SearchString) = Ucase(TwoDimList(i,0)) Then
280*cdf0e10cSrcweir			FindSecondValue = TwoDimList(i,1)
281*cdf0e10cSrcweir			Exit For
282*cdf0e10cSrcweir		End If
283*cdf0e10cSrcweir	Next
284*cdf0e10cSrcweirEnd Function
285*cdf0e10cSrcweir
286*cdf0e10cSrcweir
287*cdf0e10cSrcweir&apos; raises a base to a certain power
288*cdf0e10cSrcweirFunction Power(Basis as Double, Exponent as Double) as Double
289*cdf0e10cSrcweir	Power = Exp(Exponent*Log(Basis))
290*cdf0e10cSrcweirEnd Function
291*cdf0e10cSrcweir
292*cdf0e10cSrcweir
293*cdf0e10cSrcweir&apos; rounds a Real to a given Number of Decimals
294*cdf0e10cSrcweirFunction Round(BaseValue as Double, Decimals as Integer) as Double
295*cdf0e10cSrcweirDim Multiplicator as Long
296*cdf0e10cSrcweirDim DblValue#, RoundValue#
297*cdf0e10cSrcweir	Multiplicator = Power(10,Decimals)
298*cdf0e10cSrcweir	RoundValue = Int(BaseValue * Multiplicator)
299*cdf0e10cSrcweir	Round = RoundValue/Multiplicator
300*cdf0e10cSrcweirEnd Function
301*cdf0e10cSrcweir
302*cdf0e10cSrcweir
303*cdf0e10cSrcweir&apos;Retrieves the mere filename out of a whole path
304*cdf0e10cSrcweirFunction FileNameoutofPath(ByVal Path as String, Optional Separator as String) as String
305*cdf0e10cSrcweirDim i as Integer
306*cdf0e10cSrcweirDim SepList() as String
307*cdf0e10cSrcweir	If IsMissing(Separator) Then
308*cdf0e10cSrcweir		Path = ConvertFromUrl(Path)
309*cdf0e10cSrcweir		Separator = GetPathSeparator()
310*cdf0e10cSrcweir	End If
311*cdf0e10cSrcweir	SepList() = ArrayoutofString(Path, Separator,i)
312*cdf0e10cSrcweir	FileNameoutofPath = SepList(i)
313*cdf0e10cSrcweirEnd Function
314*cdf0e10cSrcweir
315*cdf0e10cSrcweir
316*cdf0e10cSrcweirFunction GetFileNameExtension(ByVal FileName as String)
317*cdf0e10cSrcweirDim MaxIndex as Integer
318*cdf0e10cSrcweirDim SepList() as String
319*cdf0e10cSrcweir	SepList() = ArrayoutofString(FileName,&quot;.&quot;, MaxIndex)
320*cdf0e10cSrcweir	GetFileNameExtension = SepList(MaxIndex)
321*cdf0e10cSrcweirEnd Function
322*cdf0e10cSrcweir
323*cdf0e10cSrcweir
324*cdf0e10cSrcweirFunction GetFileNameWithoutExtension(ByVal FileName as String, Optional Separator as String)
325*cdf0e10cSrcweirDim MaxIndex as Integer
326*cdf0e10cSrcweirDim SepList() as String
327*cdf0e10cSrcweir	If not IsMissing(Separator) Then
328*cdf0e10cSrcweir		FileName = FileNameoutofPath(FileName, Separator)
329*cdf0e10cSrcweir	End If
330*cdf0e10cSrcweir	SepList() = ArrayoutofString(FileName,&quot;.&quot;, MaxIndex)
331*cdf0e10cSrcweir	GetFileNameWithoutExtension = RTrimStr(FileName, &quot;.&quot; &amp; SepList(MaxIndex)
332*cdf0e10cSrcweirEnd Function
333*cdf0e10cSrcweir
334*cdf0e10cSrcweir
335*cdf0e10cSrcweirFunction DirectoryNameoutofPath(sPath as String, Separator as String) as String
336*cdf0e10cSrcweirDim LocFileName as String
337*cdf0e10cSrcweir	LocFileName = FileNameoutofPath(sPath, Separator)
338*cdf0e10cSrcweir	DirectoryNameoutofPath = RTrimStr(sPath, Separator &amp; LocFileName)
339*cdf0e10cSrcweirEnd Function
340*cdf0e10cSrcweir
341*cdf0e10cSrcweir
342*cdf0e10cSrcweirFunction CountCharsinString(BigString, LocChar as String, ByVal StartPos as Integer) as Integer
343*cdf0e10cSrcweirDim LocCount%, LocPos%
344*cdf0e10cSrcweir	LocCount = 0
345*cdf0e10cSrcweir	Do
346*cdf0e10cSrcweir		LocPos = Instr(StartPos,BigString,LocChar)
347*cdf0e10cSrcweir		If LocPos &lt;&gt; 0 Then
348*cdf0e10cSrcweir			LocCount = LocCount + 1
349*cdf0e10cSrcweir			StartPos = LocPos+1
350*cdf0e10cSrcweir		End If
351*cdf0e10cSrcweir	Loop until LocPos = 0
352*cdf0e10cSrcweir	CountCharsInString = LocCount
353*cdf0e10cSrcweirEnd Function
354*cdf0e10cSrcweir
355*cdf0e10cSrcweir
356*cdf0e10cSrcweirFunction BubbleSortList(ByVal SortList(),optional sort2ndValue as Boolean)
357*cdf0e10cSrcweir&apos;This function bubble sorts an array of maximum 2 dimensions.
358*cdf0e10cSrcweir&apos;The default sorting order is the first dimension
359*cdf0e10cSrcweir&apos;Only if sort2ndValue is True the second dimension is the relevant for the sorting order
360*cdf0e10cSrcweir	Dim s as Integer
361*cdf0e10cSrcweir	Dim t as Integer
362*cdf0e10cSrcweir	Dim i as Integer
363*cdf0e10cSrcweir	Dim k as Integer
364*cdf0e10cSrcweir	Dim dimensions as Integer
365*cdf0e10cSrcweir	Dim sortvalue as Integer
366*cdf0e10cSrcweir	Dim DisplayDummy
367*cdf0e10cSrcweir	dimensions = 2
368*cdf0e10cSrcweir
369*cdf0e10cSrcweirOn Local Error Goto No2ndDim
370*cdf0e10cSrcweir	k = Ubound(SortList(),2)
371*cdf0e10cSrcweir	No2ndDim:
372*cdf0e10cSrcweir	If Err &lt;&gt; 0 Then dimensions = 1
373*cdf0e10cSrcweir
374*cdf0e10cSrcweir	i = Ubound(SortList(),1)
375*cdf0e10cSrcweir	If ismissing(sort2ndValue) then
376*cdf0e10cSrcweir		sortvalue = 0
377*cdf0e10cSrcweir	else
378*cdf0e10cSrcweir		sortvalue = 1
379*cdf0e10cSrcweir	end if
380*cdf0e10cSrcweir
381*cdf0e10cSrcweir	For s = 1 to i - 1
382*cdf0e10cSrcweir		For t = 0 to i-s
383*cdf0e10cSrcweir			Select Case dimensions
384*cdf0e10cSrcweir			Case 1
385*cdf0e10cSrcweir				If SortList(t) &gt; SortList(t+1) Then
386*cdf0e10cSrcweir					DisplayDummy = SortList(t)
387*cdf0e10cSrcweir					SortList(t) = SortList(t+1)
388*cdf0e10cSrcweir					SortList(t+1) = DisplayDummy
389*cdf0e10cSrcweir				End If
390*cdf0e10cSrcweir			Case 2
391*cdf0e10cSrcweir				If SortList(t,sortvalue) &gt; SortList(t+1,sortvalue) Then
392*cdf0e10cSrcweir					For k = 0 to UBound(SortList(),2)
393*cdf0e10cSrcweir							DisplayDummy = SortList(t,k)
394*cdf0e10cSrcweir							SortList(t,k) = SortList(t+1,k)
395*cdf0e10cSrcweir							SortList(t+1,k) = DisplayDummy
396*cdf0e10cSrcweir					Next k
397*cdf0e10cSrcweir				End If
398*cdf0e10cSrcweir			End Select
399*cdf0e10cSrcweir		Next t
400*cdf0e10cSrcweir	Next s
401*cdf0e10cSrcweir	BubbleSortList = SortList()
402*cdf0e10cSrcweirEnd Function
403*cdf0e10cSrcweir
404*cdf0e10cSrcweir
405*cdf0e10cSrcweirFunction GetValueoutofList(SearchValue, BigList(), iDim as Integer, Optional ValueIndex)
406*cdf0e10cSrcweirDim i as Integer
407*cdf0e10cSrcweirDim MaxIndex as Integer
408*cdf0e10cSrcweir	MaxIndex = Ubound(BigList(),1)
409*cdf0e10cSrcweir	For i = 0 To MaxIndex
410*cdf0e10cSrcweir		If BigList(i,0) = SearchValue Then
411*cdf0e10cSrcweir			If Not IsMissing(ValueIndex) Then
412*cdf0e10cSrcweir				ValueIndex = i
413*cdf0e10cSrcweir			End If
414*cdf0e10cSrcweir			GetValueOutOfList() = BigList(i,iDim)
415*cdf0e10cSrcweir		End If
416*cdf0e10cSrcweir	Next i
417*cdf0e10cSrcweirEnd Function
418*cdf0e10cSrcweir
419*cdf0e10cSrcweir
420*cdf0e10cSrcweirFunction AddListtoList(ByVal FirstArray(), ByVal SecondArray(), Optional StartIndex)
421*cdf0e10cSrcweirDim n as Integer
422*cdf0e10cSrcweirDim m as Integer
423*cdf0e10cSrcweirDim MaxIndex as Integer
424*cdf0e10cSrcweir	MaxIndex = Ubound(FirstArray()) + Ubound(SecondArray()) + 1
425*cdf0e10cSrcweir	If MaxIndex &gt; -1 Then
426*cdf0e10cSrcweir		Dim ResultArray(MaxIndex)
427*cdf0e10cSrcweir		For m = 0 To Ubound(FirstArray())
428*cdf0e10cSrcweir			ResultArray(m) = FirstArray(m)
429*cdf0e10cSrcweir		Next m
430*cdf0e10cSrcweir		For n = 0 To Ubound(SecondArray())
431*cdf0e10cSrcweir			ResultArray(m) = SecondArray(n)
432*cdf0e10cSrcweir			m = m + 1
433*cdf0e10cSrcweir		Next n
434*cdf0e10cSrcweir		AddListToList() = ResultArray()
435*cdf0e10cSrcweir	Else
436*cdf0e10cSrcweir		Dim NullArray()
437*cdf0e10cSrcweir		AddListToList() = NullArray()
438*cdf0e10cSrcweir	End If
439*cdf0e10cSrcweirEnd Function
440*cdf0e10cSrcweir
441*cdf0e10cSrcweir
442*cdf0e10cSrcweirFunction CheckDouble(DoubleString as String)
443*cdf0e10cSrcweirOn Local Error Goto WRONGDATATYPE
444*cdf0e10cSrcweir	CheckDouble() = CDbl(DoubleString)
445*cdf0e10cSrcweirWRONGDATATYPE:
446*cdf0e10cSrcweir	If Err &lt;&gt; 0 Then
447*cdf0e10cSrcweir		CheckDouble() = 0
448*cdf0e10cSrcweir		Resume NoErr:
449*cdf0e10cSrcweir	End If
450*cdf0e10cSrcweirNOERR:
451*cdf0e10cSrcweirEnd Function
452*cdf0e10cSrcweir</script:module>