Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,220,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Remove Quotes", 10,10,150,20
Control Add TextBox, hDlg, 200,"This is " + Chr$(34) + "some quoted text" + Chr$(34) + " for testing", 10,40,200,20
Control Add TextBox, hDlg, 300,"", 10,70,200,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$
If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
Control Get Text hDlg, 200 To temp$
Control Set Text hDlg, 300, RemoveQuotedStrings(temp$)
End If
End Function
Function RemoveQuotedStrings(ByVal strSource As String) As String
Local boolQuotedText, lngSourceIndex, lngSourceLen As Long
Local pbytSource As Byte Ptr
lngSourceLen = Len( strSource )
pbytSource = StrPtr( strSource )
boolQuotedText = %FALSE
For lngSourceIndex = 0 To lngSourceLen - 1
If @pbytSource[ lngSourceIndex ] = 34 Then
boolQuotedText = Not boolQuotedText
@pbytSource[ lngSourceIndex ] = 255
End If
If IsTrue( boolQuotedText ) Then @pbytSource[ lngSourceIndex ] = 255
Next lngSourceIndex
Function = Remove$(strSource, Chr$(255))
End Function
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,220,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Remove Quotes", 10,10,150,20
Control Add TextBox, hDlg, 200,"This is " + Chr$(34) + "some quoted text" + Chr$(34) + " for testing", 10,40,200,20
Control Add TextBox, hDlg, 300,"", 10,70,200,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local temp$
If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
Control Get Text hDlg, 200 To temp$
Control Set Text hDlg, 300, RemoveQuotedStrings(temp$)
End If
End Function
Function RemoveQuotedStrings(ByVal temp$) As String
Local iStart, iEnd As Long
iStart = 1
Do
iStart = InStr(iStart,temp$,$Dq)
If iStart Then
iEnd = InStr(iStart+1,temp$,$Dq)
Mid$(temp$,iStart,iEnd-iStart+1) = String$(iEnd-iStart+1,Chr$(255))
iStart = iEnd + 1
End If
Loop While iStart
Function = Remove$(temp$, Chr$(255))
End Function
'gbs_01365
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm