[Gambas-user] Problem with String[]

Jussi Lahtinen jussi.lahtinen at gmail.com
Mon Nov 21 03:35:40 CET 2022


Advice for the next time, two ways:

1. Start your program and pause it (or start it by step). Open the
debugging tab (right next to the console tab) and add expression(s) for
watch, example "EKT_orderby = null".
Restart or continue running the program and now it stops right away when
the condition you gave is satisfied. If this doesn't work for some reason,
try #2 below.

2. When the error happens see the stack (many times just browsing the stack
is enough to see what happened) and place a breakpoint approx in the middle
of it.
Run the program again repeating the thing that raises the error, and see if
the object is still null at this point, if so repeat (considering the
current line as the error). If not, place the next breakpoint between that
line and the occurrence of the actual error. Repeat until you see the
offending line.

By using these methods, you should find this kind of problem in just a few
minutes, even from a very big project.
I have a 50k lines project and finding forgotten "new" has never been a
problem. But sometimes you just don't see what is front of you. In that
case sleep might help...


Jussi


On Sun, Nov 20, 2022 at 11:34 PM Dag JNJ <gambas at cd-bahia.com> wrote:

>
>
> Am 18.11.22 um 17:51 schrieb T Lee Davidson:
>
> On 11/17/22 13:25, Dag JNJ wrote:
>
> Hi all,
> I have defined this:
>
> P/ublic arorder As New String[]//
> //Public arorderb As New String[]//
> /
> and make this in a subroutine:
>
> /    arorder.Add(fld)//
> //    arorderb.Add(ada)
>
> ///
> /fld/ contains a field name, /ada/ = "ASC"
>
> the first assignment with /aroder/ succeeds, the second with /arorderb/
> makes an error : null object
> I can't see any difference between these objects, and they are only
> changed in  this routine (so far).
> I am thankful for any help, allt he best, Dag JNJ
>
>
> It is quite difficult to determine what may be causing that without seeing
> the full code. Perhaps somewhere 'arorderb' is getting nullified. Can you
> pare it down to a small project, that reproduces the issue, that you can
> share?
>
>
>
> Thanks for the feedback.
> I made a silly (beginners!) error.
>
> I defined EKT_order and EKT_orderby by like this:  _
> *Public EKT_order as *
> *New  String[] *
>
> *Public EKT_orderby as String[] *and called a Procedure
>
> *MakeOrderType(EKT order , *
>
> *EKT orderby,, fld , Column) *
>
> *Public Procedure MakeOrderType(arorder As String[], arordorb As String[],
> fld As String, clmn As Byte) *Shame on me, cost me almost two days
> seeking the error. I just forgot New. Found it at last. Really embarrassing.
>
>
> Best regards,
> Dag
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221121/b8036443/attachment-0001.htm>


More information about the User mailing list