PARSESET$() Again
issueid=4 18-10-2010 08:05
Member
Number of reported issues by gungadout: 2
PARSESET$() Again

Hi Folks,

Please run this code. See if you see anything strange after the PARSESET$() is executed.

I am using @(6)@ as a unique delimiter, because the CHR$(254) that I will ultimately be using, erases the contents of message boxes (or at least it used to).

' Empty GUI script created on 10-18-2010 15:49:52 by (ThinAIR)
 
 Dim baa1  As String = "@(6)@@(6)@@(6)@@(6)@"
 Dim AM   As String = "@(6)@"  
 Dim Baa2  As String
 Dim Baa3  As String
 Dim Booter As Long = 4
 Dim Four  As String = "4"
 
 Dim DelimiterCount As Long
 Dim DelimiterAdds As String
  
 DelimiterCount = ParseCount(Baa1, AM)
 DelimiterAdds = Repeat$(6, AM) 
 Baa2 = Baa1 + DelimiterAdds 
MsgBox(0, Baa2 + " " + DelimiterCount) 
' Baa3 = ParseSet$(Baa2, AM, 4, Format$(Booter))      ' Try both these instructions
 Baa3 = ParseSet$(Baa2, AM, 4, Four)            ' Try both these instructions

MsgBox(0, Baa1 + "  " + Baa2 + "  " + Baa3)
I think I'm using the instruction properly.

I'm still running version 1.8.0.0. Is the latest stable version 1.8.5.0? Would that help?

Regards,

Peter H.
Issue Details
Issue Number 4
Project thinBasic
Category Core engine (thinCore.dll)
Status Fixed
Priority Unknown
Affected Version 1.8.7
Fixed Version 1.8.8
Milestone thinBasic 1.8.8.0
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




18-10-2010 10:02
Super Moderator
I think this classifies as bug, thanks for reporting it!

In the mean time, please use this ThinBASIC function instead:
 Function CustomParseSet(sMainString As String, sDelimiter As String, index As Long, sNew As String) As String
  Dim fields() As String
  Dim nFields As Long = Parse(sMainString, fields, sDelimiter)
  
  fields(index) = sNew

  Return Join$(fields, sDelimiter)  
 End Function
I am moving this post to bug report.


Petr

19-10-2010 06:30
Member
Hi Petr,

Thanks for the workaround.

Regards,

Peter H.

02-12-2010 09:37
Member
Hi Petr,

I have an update for the CustomParseSet function you put together for me.

  Function CustomParseSet(sMainString As String, sDelimiter As String, index As Long, sNew As String) As String
    Dim fields() As String
    Dim nFields As Long = Parse(sMainString, fields, sDelimiter)
'--<<    
    If nFields < index Then
      ReDim Preserve fields(index)    
    End If
'-->>     
    fields(index) = sNew
 
    Return Join$(fields, sDelimiter)    
  End Function
This caters for the required data position being beyond the current count of fields in the string.

Regards,

Peter H. (gungadout)

02-12-2010 10:58
Super Moderator
Very nice,

thanks a lot for sharing the code!


Petr

29-05-2011 12:48
thinBasic author
Fixed. Will be present in next release.
Mainly the resulting string was taking as delimiter only the first char of the delimiter and not full delimiter string.
Now is ANY clause is used, only the first char of delimiter is taken. If ANY is NOT used, delimiter will remain as it was passed.

+ Reply