Using break and watching with the array uncommented
the type is showing as variant?? without it type is
showing as long?
watching array gives variant with value 0 to -1?? if
defined or not defined?
With line commented it gives value type as Long.
Sub ResizeArrayTest
Dim MyArray(6) as Long, i as Long
rem MyArray()=array(1, 2988,
3, 488, 5888, 688)
for i = 0 to 5
MyArray(i)=(i+1)*100
print MyArray (i)
next i
ReDim Preserve MyArray( 4 ) As Long
for i = 0 to 3
print MyArray (i)
next i
End Sub
Put a break on both print statements and watch Myarray
and array
On 10 Jul 2022 at 14:59, Remy Gauthier wrote:
Subject:Re: [libreoffice-users] ReDim Preserve
(BASIC macro programming)
From: Remy Gauthier
To: Johnny Rosenberg
, LibreOffice
Användare
Date sent: Sun, 10 Jul 2022 14:59:29 -0400
> Hi,
>
> I can reproduce your issue on LO 7.3.4.2 on Fedora 35.
> Not 100% familiar with LO Basic, but this code works:
>
> Sub resizeArrayTest
>
> dim myArray (5) As Long
> for i = 0 to 5
> myArray (i) = i
> next i
>
> ReDim Preserve myArray (4)
> End Sub
>
> Sub Main
>
> call resizeArrayTest
>
> End Sub
>
> It seems the Array() function you are using returns something that
> cannot be ReDim'ed, which may explain your observation.
>
> I hope this helps.
> Rémy.
>
>
>
> Le dimanche 10 juillet 2022 à 20:02 +0200, Johnny Rosenberg a écrit :
> > Hi.
> >
> > Is this a bug or is my brain just not working?
> >
> >
> >
> >
> >
> > *Sub ResizeArrayTest Dim MyArray(5) As Long MyArray=Array(1,
> > 2, 3,
> > 4, 5, 6) ReDim Preserve MyArray(4)End Sub*
> >
> > Running this creates the array MyArray, but it's *empty*, so it seems
> > like "
> > *Preserve*" doesn't work here. Or what am I doing wrong? I'm sure I
> > have
> > got Preserve to work many times before, but maybe my brain crashed
> > this
> > time.
> >
> > Using LibreOffice 7.2.7.2 on Ubuntu Studio 20.04.
> >
> > Kind regards
> >
> > Johnny Rosenberg
> >
>
>
> --
> To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
> Problems?
> https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
> Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
> List archive: https://listarchives.libreoffice.org/global/users/
> Privacy Policy: https://www.documentfoundation.org/privacy
++
Michael D. Setzer II - Computer Science Instructor
(Retired)
mailto:mi...@guam.net
mailto:msetze...@gmail.com
Guam - Where America's Day Begins
G4L Disk Imaging Project maintainer
http://sourceforge.net/projects/g4l/
++
--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy