-
Notifications
You must be signed in to change notification settings - Fork 1
/
strings.bas
77 lines (61 loc) · 1.34 KB
/
strings.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Include Once
Function FindFirstOf(item$, search_string$)
For i = 0 to length(search_string$)-1
If Mid(search_string$, i, length(item$)) = item$ Then
Return i
End If
Next
Return -1
End Function
Function FindNextOf(item$, search_string$, start)
If start >= length(search_string$) Then
Return -1
End If
For i = start to length(search_string$) - 1
If Mid(search_string$, i, length(item$)) = item$ Then
Return i
End If
Next
Return -1
End Function
Function FindLastOf(item$, search_string$)
If length(search_string$) <= 0 Then
Return -1
End If
last_index = -1
For i = 0 to length(search_string$)-1
If Mid$(search_string$, i, 1) = item$ Then
last_index = i
End If
Next
Return last_index
End Function
MAX_LIST_SIZE = 32767
Function Split(list_string$, delimeter$, ByRef list_out$)
Dim v$[MAX_LIST_SIZE]
list_string$ = Trim$(list_string$) + delimeter$
arg$ = ""
arg_num = 0
For i = 0 to Len(list_string$)-1
c$ = Mid(list_string$, i, 1)
If c$ = delimeter$ Then
v$[arg_num] = arg$
arg_num = arg_num + 1
arg$ = ""
Else
arg$ = arg$ + c$
End If
Next
For i = 0 to arg_num-1
list_out$[i] = v$[i]
Next
Return arg_num
End Function
Function InList(ByRef list$, list_count, item$)
For i = 0 to list_count-1
If item$ = list$[i] Then
Return True
End If
Next
Return False
End Function