Found an issue in SpiderBasic ? Please report it here !
DanLJr
 
Posts: 13
Joined: Wed Jul 04, 2018 4:24 am

ArraySize() doesn't properly reflect the Array's size (BUG?)

by DanLJr Wed Jul 18, 2018 11:51 pm

ArraySize() doesn't properly reflect the size of the Array after populating an Array from a function:

Code: Select all
Dim UserInputParsedArray$(0)

CreateRegularExpression(0, "\w+")
NumberOfElements = ExtractRegularExpression(0, "qwerty asdf zxcv poiuytr", UserInputParsedArray$()) ;NumberOfElements returns 4 (four matches found)
Debug NumberOfElements ;shows 4
Debug  ArraySize(UserInputParsedArray$()) ;show 0 !!!???
;yet...

For i = 0 To 3
  Debug UserInputParsedArray$(i)
Next
;shows all elements, so ArraySize(UserInputParsedArray$()) should definitely return 4, otherwise ArraySize() is useless without running the RegEx twice with a ReDim in the middle - huh??? HOW??? Is this a bug?


Is this a bug? If not, it's never weird and undesireable behanvior.

Thoughts?
DanLJr
 
Posts: 13
Joined: Wed Jul 04, 2018 4:24 am

Re: ArraySize() doesn't properly reflect the Array's size (B

by DanLJr Sat Jul 21, 2018 1:37 am

*BUMP*???

Thinking about this, I could force a ReDim manually AFTER the {NumberOfElements = ExtractRegularExpression(0,...} so that ArraySize() would reflect the actual size, but really what is the point of ReDim and ArraySize() if it's just a "manual" process to maintain it anyhow?

Also, if I do go ahead and ReDim throughout the loop just to maintain consistency with ArraySize() (in a real-world application this loop would not be fixed to four values, rather a dynamic number of values) does it just waste additional resources? Should I just ignore ReDim and ArraySize() altogether, since they seem to do nothing and appear to have no ill effects when ignored? (Other than the ability to know the array's size without manually looping after-the-fact.)

Last related question...since the array in the example below is an argument being passed by reference to the ExtractRegularExpression function (part of the PureBasic libraries; not a user-defined function) shouldn't that function be the one to ReDim the array internally? (Is this a bad/missed implementation of the regular expression functions that manipulate arrays?)

Fred, anybody?

BTW, SpiderBasic is proving to be an AWESOME product! I'm been coding my first relatively serious project (first in SB; I've been around for a while...) in the demo version, and I'm about to purchase. Next will be to start working on some server-side stuff in PB and see if I can master the SB-PB development relationship via HTTP/JSON, etc.

Overall I"m VERY impressed and happy with SB! (Now, if we can just workout some of these array bugs / undesirable behavious...LOL)

DanLJr wrote:ArraySize() doesn't properly reflect the size of the Array after populating an Array from a function:

Code: Select all
Dim UserInputParsedArray$(0)

CreateRegularExpression(0, "\w+")
NumberOfElements = ExtractRegularExpression(0, "qwerty asdf zxcv poiuytr", UserInputParsedArray$()) ;NumberOfElements returns 4 (four matches found)
Debug NumberOfElements ;shows 4
Debug  ArraySize(UserInputParsedArray$()) ;show 0 !!!???
;yet...

For i = 0 To 3
  Debug UserInputParsedArray$(i)
Next
;shows all elements, so ArraySize(UserInputParsedArray$()) should definitely return 4, otherwise ArraySize() is useless without running the RegEx twice with a ReDim in the middle - huh??? HOW??? Is this a bug?


Is this a bug? If not, it's never weird and undesireable behanvior.

Thoughts?
User avatar
Peter
 
Posts: 531
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: ArraySize() doesn't properly reflect the Array's size (B

by Peter Sat Jul 21, 2018 3:28 pm

<OT>

DanLJr wrote:Next will be to start working on some server-side stuff in PB and see if I can master the SB-PB development relationship via HTTP/JSON, etc.

maybe that's worth a look: SpiderBite

</OT>

Greetings ... Peter
DanLJr
 
Posts: 13
Joined: Wed Jul 04, 2018 4:24 am

Re: ArraySize() doesn't properly reflect the Array's size (B

by DanLJr Mon Jul 23, 2018 12:57 am

Peter wrote:<OT>

DanLJr wrote:Next will be to start working on some server-side stuff in PB and see if I can master the SB-PB development relationship via HTTP/JSON, etc.

maybe that's worth a look: SpiderBite

</OT>

Greetings ... Peter


Ok, so I did a quick read on SpiderBite. The big question is, does this ACTUALLY work? Like well? Production-level?

If it does what it says, this would make developing the server-side of my apps (and the client-side communication as well) as simple as making a begin and end do each desired section of server-side code. A few smart decisions, and, "voilĂ !" you have a full-featured, client/server web/app with SpiderBasic-as-primary/only dev tool needed. (I mean, you need a PureBasic license along with SpiderBasic, but you would anyway.)

This is a BEAUTIFUL thing, Peter!

I'm going to give it a shot as soon as I get closer to deployment. It will be quite easy to mark the server-sde areas later, since I don't need to develop using any database access at this time. (Though, I WILL need to build some components with server-side DB access at some point in the future.) I'll let you know how things go with SpiderBite as soon as I get to the point where I'm ready to give it a shot! (And inline PHP could offer an easy solution to integrate things like WP - SB/PB WP plugin dev??? - by dropping-in their "rules layer" without separating the programming task beyond MAYBE having to copy a part to the right place on the server manually and changing a path or two in PHP code after-the-fact???. Interesting...)

Anything special - "gotchas"/limitations - I should know about here? (Besides the "no hardware access on the server" kinda obvious stuff?)

Exciting stuff, Peter!
Return to Bugs Reports

Who is online

Users browsing this forum: No registered users and 1 guest