-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfut_stng.bas
More file actions
95 lines (95 loc) · 3.71 KB
/
fut_stng.bas
File metadata and controls
95 lines (95 loc) · 3.71 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Rem This file is part of the 'File Update Tool' program.
Rem Copyright (C) 2025 Ihar S. Areshchankau
Rem
Rem This program is free software: you can redistribute it and/or modify
Rem it under the terms of the GNU General Public License as published by
Rem the Free Software Foundation, either version 3 of the License, or
Rem (at your option) any later version.
Rem
Rem This program is distributed in the hope that it will be useful,
Rem but WITHOUT ANY WARRANTY; without even the implied warranty of
Rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Rem GNU General Public License for more details.
Rem
Rem You should have received a copy of the GNU General Public License
Rem along with this program. If not, see <https://www.gnu.org/licenses/>.
Rem
Rem ====================================
Rem Ìîäóëü ðàáîòû ñ íàñòðîéêàìè ñèñòåìû.
Rem ßçûê ïðîãðàììèðîâàíèÿ: FreeBasic.
Rem ====================================
Dim Shared Settings(Any) As String, Values(Any) As String, Initialized(Any) As Integer
Rem =========================================
Rem Ïîäãîòîâêà ê ðàáîòå ñ ïåðå÷íåì íàñòðîåê.
Rem Âûçîâ: s - ñòðîêà ñ ïåðå÷íåì íàñòðîåê,
Rem c - ðàçäåëèòåëü íàñòðîåê â ñòðîêå.
Rem =========================================
Public Sub stngInit (ByRef s As Const String, ByRef c As String = "^")
Dim i As Integer, p As Integer, r As Integer, n As Integer, lc As Integer
Rem Ïîäñ÷¸ò êîëè÷åñòâà íàñòðîåê
n = 0
If "" <> s Then
n = 1 ' ïåðâàÿ íàñòðîéêà - äî ðàçäåëèòåëÿ
lc = Len (c)
p = InStr (s, c)
While p > 0 AndAlso Asc (s, p) <> 0
n += 1
p = InStr (p + lc, s, c)
Wend
End If
Rem Ôîðìèðîâàíèå ìàññèâîâ íàñòðîåê è èõ çíà÷åíèé.
If n > 0 Then
Redim Settings(n - 1), Values(n - 1), Initialized(n - 1)
p = 1
r = InStr (s, c)
For i = 0 To n - 1
Settings(i) = Mid (s, p, Iif (r > 0, r, 1 + Len (s)) - p)
p = r + lc
r = InStr (p, s, c)
Next i
End If
End Sub
Rem =======================================
Rem Ïîèñê óêàçàííîé íàñòðîéêè.
Rem Âûçîâ: s - íàçâàíèå íàñòðîéêè.
Rem Âîçâðàò: èíäåêñ íàñòðîéêè â ìàññèâå èëè
Rem -1, åñëè íàñòðîéêà íå íàéäåíà.
Rem =======================================
Private Function stngFind (ByRef s As Const String) As Integer
Dim i As Integer, n As Integer
i = LBound (Settings)
n = UBound (Settings)
While i <= n AndAlso Settings(i) <> s
i += 1
Wend
stngFind = Iif (i > n, -1, i)
End Function
Rem ========================================
Rem Óñòàíîâêà çíà÷åíèÿ íàñòðîéêè.
Rem Âûçîâ: s - íàçâàíèå íàñòðîéêè,
Rem v - çíà÷åíèå íàñòðîéêè,
Rem o - ðàçðåøåíèå íà ïåðåçàïèñü.
Rem Âîçâðàò: -1 - çíà÷åíèå óñòàíîâëåíî,
Rem 0 - îøèáêà óñòàíîâêè çíà÷åíèÿ.
Rem ========================================
Public Function stngSetValue (ByRef s As Const String, ByRef v As Const String, ByVal o As Integer) As Integer
Dim i As Integer = stngFind (s), res As Integer = 0
i = stngFind (s)
If i >= 0 AndAlso (Initialized(i) = 0 OrElse o)Then
Values(i) = v
Initialized(i) = -1
res = -1
End If
stngSetValue = res
End Function
Rem =====================================
Rem Ïîëó÷åíèå çíà÷åíèÿ íàñòðîéêè.
Rem Âûçîâ: s - íàçâàíèå íàñòðîéêè.
Rem Âîçâðàò: çíà÷åíèå íàñòðîéêè.
Rem Ïðèìå÷àíèå. Åñëè íàñòðîéêà íå çàäàíà,
Rem òî âîçâðàùàåòñÿ ïóñòàÿ ñòðîêà.
Rem =====================================
Public Function stngGetValue (ByRef s As Const String) As String
Dim i As Integer = stngFind (s)
stngGetValue = Iif (i >= 0, Values(i), "")
End Function