Issue 25739 - ReDim Preserve vItems(iCount) fails
Summary: ReDim Preserve vItems(iCount) fails
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: ab
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-20 19:40 UTC by andrew
Modified: 2013-02-24 21:09 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description andrew 2004-02-20 19:40:50 UTC
vItems() is a variant.

In the example that I have seen, iCount is 77 AND UBound(vItems()) is also 77. 
This does not always fail, it typically fails the second time through. I can 
provide the complete set of code if required.

No errors are generated, but the macro simply stops and that line is 
highlighted. I have not stared at the code for long, but this line might not 
be required. I created a working solution by only changing the dimension when 
it is required.


  Print "iCount = " & iCount & " ub = " & UBound(vItems())
  If iCount <> UBound(vItems()) Then
    ReDim Preserve vItems(iCount)
  End If
Comment 1 andrew 2004-02-20 19:43:12 UTC
Okay, when will I be able to assign such things directly to scripting. I 
thought that I could reassign this to scripting at least after I created it 
and also assign it to ab! Drat!\

Oh yeah, this was not a problem in 1.1.0.
Comment 2 andrew 2004-02-22 05:55:11 UTC
I was told to mention that this is REGRESSION. This is a new bug with 1.1.1b
that does not exist in 1.1.0.


When I ran this code, I had an empty document and the macro. Nothing more. If
you download my main libraries

http://www.pitonyak.org/PitonyakLibs.zip

You will need the Pitonyak and PitonyakDialogs library. Use the PitonyakDialogs
and then use the module that contains the RunSimpleObjectBrowser() routine and
just run the main routine.....
Comment 3 ab 2004-02-25 10:50:51 UTC
Probably duplicate to internal StarOffice pp2 regression task. I will check this...
Comment 4 andrew 2004-02-25 15:43:20 UTC
Run this macro. I trimmed it down to 109 lines. I could have trimmed it more 
but....


Option Explicit

Sub TheMain
  Dim iCount%, j%, iPos%, sNew$, oItems(), i%
  Dim s$, sep$
  s$ = ThisComponent.DBG_Properties
  sep$ = ";"
  Call BuildItemArray(s$, sep$, oItems())
End Sub



'*************************************************************************
'** Find the first character starting at location i% that is not whitespace.
'** If there are none, then the return value will be greater than the 
'** length of the string.
'*************************************************************************
Function FirstNonWhiteSpace(ByVal i%, s$) As Integer
  If i <= Len(s) Then
    Do While IsWhiteSpace(Asc(Mid$(s, i, 1)))
      i = i + 1
      If i > Len(s) Then
        Exit Do
      End If
    Loop
  End If
  FirstNonWhiteSpace = i
End Function

'*************************************************************************
'** Is the specified character whitespace? The answer is true if the
'** character is a tab, CR, LF, space, or a non-breaking space character!
'** These correspond to the ASCII values 9, 10, 13, 32, and 160
'*************************************************************************
Function IsWhiteSpace(iChar As Integer) As Boolean
  Select Case iChar
  Case 9, 10, 13, 32, 160
    IsWhiteSpace = True
  Case Else
    IsWhiteSpace = False
  End Select  
End Function

Function ADPTrim(s As String) As String
  s = Trim(s)
  Do While Len(s) > 0
    If Not IsWhiteSpace(ASC(s)) Then Exit Do
    s = Right(s, Len(s) - 1)
  Loop
  Do While Len(s) > 0
    If Not IsWhiteSpace(ASC(Right(s, 1))) Then Exit Do
    s = Left(s, Len(s) - 1)
  Loop
  ADPTrim = s
End Function

'*************************************************************************
'** This routine parses the strings returned from the dbg_Methods,
'** dbg_Properties, and dbg_SupportedServices calls. The interesting
'** data starts after the first colon.
'** 
'** Because of this, all data before the first colon is discarded
'** and then the string is separated into pieces based on the
'** separator string that is passed in.
'** 
'** All instances of the string Sbx are removed. If this string
'** is valid and exists in a method name, it will still be removed so perhaps
'** it is not the safest thing to do, but I have never seen this case and it
'** makes the output easier to read.
'**
'** the vItems() contains all of the parsed sections on output.
'**
'**
'*************************************************************************
Sub BuildItemArray(s$, sep$, vItems())
  On Error Goto BadErrorHere
  Dim iCount%, iPos%, sNew$, i%, j%
  Dim sFront() As String, sMid() As String
  Dim iIdx() As Integer
  Dim nFrontMax As Integer  'Maximum length of front section

  nFrontMax = 0

  REM First, we only care about what is after the colon.
  iPos = InStr(1, s, ":") + 1
  If iPos > 0 Then s = ADPTrim(Right(s, Len(s) - iPos))
  
  REM Now, remove all of the "SbX" charcters
  s = Join(Split(s, "Sbx"), "")
  If ASC(sep$) <> 10 Then s = Join(Split(s, CHR$(10)), "")
  
  REM split on the separator character
  vItems() = Split(s, sep$)

  Rem Create arrays to hold the different portions of the text.
  Rem the string usually contains text similar to "SbxString getName()"
  Rem sFront() holds the data type if it exists and "" if it does not.
  Rem sMid() holds the rest
  ReDim sFront(UBound(vItems)) As String
  ReDim sMid(UBound(vItems))   As String
  ReDim iIdx(UBound(vItems))   As Integer
  
  iCount = UBound(vItems())
  ReDim Preserve vItems(iCount)
  Exit Sub
BadErrorHere:
  MsgBox "Error " & err & ": " & error$ + chr(13) + "In line : " + Erl
End Sub
Comment 5 andrew 2004-03-03 00:02:29 UTC
This seems to be fixed in 1.1.1rc on my linux computer! I have not yet tested
this on my windows computer at work.
Comment 6 ab 2004-03-04 10:48:38 UTC
I haven't found time so far to verify it, but this confirms my assumption that
this task
is duplicate to an StarOffice internal task that has already been fixed for PP2.
This
task also deals with arrays passed as parameters.
Comment 7 ab 2004-08-04 11:30:26 UTC
Could not reproduce any more on src680 m43, so I set this task to fixed.
Comment 8 ab 2005-01-25 15:56:31 UTC
-> Closed