Quoting constructs: Difference between revisions

Content added Content deleted
(add to bQN)
(Quoting constructs en FreeBASIC)
Line 49: Line 49:
** Strings <lang bqn>"Hello World"
** Strings <lang bqn>"Hello World"
"Quoted "" String"</lang> any sequence of characters including newlines can be put inside a string. Quotes are escaped by typing two quotes.
"Quoted "" String"</lang> any sequence of characters including newlines can be put inside a string. Quotes are escaped by typing two quotes.

=={{header|FreeBASIC}}==
{{trans|Ring}}
<lang freebasic>'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</lang>
{{out}}
<pre>Same as Ring input.</pre>


=={{header|Go}}==
=={{header|Go}}==