Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/Quoting-constructs/FreeBASIC/quoting-constructs.basic
Normal file
31
Task/Quoting-constructs/FreeBASIC/quoting-constructs.basic
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'In FB there is no substr function, then
|
||||
'Function taken fron the https://www.freebasic.net/forum/index.php
|
||||
|
||||
Function substr(Byref soriginal As String, Byref spattern As Const String, Byref sreplacement As Const String) As String
|
||||
' in <soriginal> replace all occurrences of <spattern> by <sreplacement>
|
||||
Dim As Uinteger p, q
|
||||
|
||||
If sreplacement <> spattern Then
|
||||
p = Instr(soriginal, spattern)
|
||||
If p Then
|
||||
q = Len(sreplacement)
|
||||
If q = 0 Then q = 1
|
||||
Do
|
||||
soriginal = Left(soriginal, p - 1) + sreplacement + Mid(soriginal, p + Len(spattern))
|
||||
p = Instr(p + q, soriginal, spattern)
|
||||
Loop Until p = 0
|
||||
End If
|
||||
End If
|
||||
Return soriginal
|
||||
End Function
|
||||
|
||||
Dim As String text(1 To 3)
|
||||
text(1) = "This is 'first' example for quoting"
|
||||
text(2) = "This is second 'example' for quoting"
|
||||
text(3) = "This is third example 'for' quoting"
|
||||
|
||||
For n As Integer = 1 To Ubound(text)
|
||||
Print !"text for quoting:\n"; text(n)
|
||||
Print !"quoted text:\n"; substr(text(n),"'",""); !"\n"
|
||||
Next n
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue