[fixed] Error on arrays while creating or assigning some vars

Things you’d like to miss in the future...
Post Reply
PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

[fixed] Error on arrays while creating or assigning some vars

Post by PeterH »

A copy of 4 stmts of a real script:

Code: Select all

   $tcmdlf[$nbrcmd + 1]	= 999;                        // to define all (prev) elements as '' (and mark end-of-array)
   $debugl	= "";                                     //   D E B U G   D E B U G   D E B U G   D E B U G   D E B U G
   echo "El. 0-4 = $tcmdlf[0] - $tcmdlf[1] - $tcmdlf[2] - $tcmdlf[3] - $tcmdlf[4]";   //   D E B U G
   $debugl	.= "0: " . Implode($tcmdlf) . <crlf>;    //   D E B U G   D E B U G   D E B U G   D E B U G   D E B U G
$nbrcmd is ~ 250, $tcmdlf is (verified!) NOT YET DEFINED!!!
The output is:
El. 0-4 = ALL CMDS - - - - (Note the "ALL CMDS" as element 0!)

These stmts executed alone show no error:
El. 0-4 = - - - -
so an example script doesn't help!

Later then, in real, elements in $tcmdlf[] will be set to 1 - in an unpredictable sequence! Then other elements sometimes appear to be set to some text, too. Some examples, change for change:
0: ALL CMDS||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||...
15: ALL CMDS|Program Control (P and C)||||||||||||||1||||||||||||||||||||
30: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1||||
167: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1|||
112: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1|||
207: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1|||
53: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1||||
202: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1|||
230: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1|||
238: ALL CMDS|Program Control (P and C)||||||||||||||1|||||||||||||||1|||
1: ALL CMDS|1|Var Handling|||||||||||||1|||||||||||||||1|||||||||||||||||
4: ALL CMDS|1|Var Handling||1|||||||||||1|||||||||||||||1||||||||||||||||
10: ALL CMDS|1|Var Handling||1||||||1|||||1|||||||||||||||1||||||||||||||
11: ALL CMDS|1|Var Handling||1||||||1|1||||1|||||||||||||||1|||||||||||||
14: ALL CMDS|1|Var Handling||1||||||1|1|||1|1|||||||||||||||1||||||||||||
21: ALL CMDS|1|Var Handling||1||||||1|1|||1|1||||||1|||||||||1|||||||||||
23: ALL CMDS|1|Var Handling||1||||||1|1|||1|1||||||1||1|||||||1||||||||||
24: ALL CMDS|1|Var Handling||1||||||1|1|||1|1||||||1||1|1||||||1|||||||||
The 1st number is the element number that just has been set.
0 = the 1st line is just after element ~250 has been set to "define" the array.

The appearing texts seem to be from another array, containing
ALL CMDS|Program Control (P and C)|Var Handling|...

Seems no good :veryconfused:

Can I give more explanations?
Or do other tests?

(Stormy weather is reaching you? I'll have some more time...)
Last edited by PeterH on 22 Jun 2023 21:03, edited 1 time in total.
Win11 Pro 223H2 Gerrman

admin
Site Admin
Posts: 60643
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Error on arrays while creating or assigning some vars

Post by admin »

Can't you narrow this down?

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Error on arrays while creating or assigning some vars

Post by PeterH »

OK - I'll try to play a bit, maybe with using some other array before doing the stmt in question.

And I had an impression as if (maybe) another strange thing with an array happened. So lets go!

(The script isn't short - but it seems in the end it will mostly contain debug lines :whistle: )
Win11 Pro 223H2 Gerrman

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Error on arrays while creating or assigning some vars

Post by PeterH »

Seems I got closer,
seems you *could* not really find it :mrgreen:

Following script when executed shows the wrong result:
§agnr = "ALL CMDS", must be =0

Comment out the UnSet stmt, retry: it's correct!

If no bug iin XY - I convince: no risk in script! :maf:

Code: Select all

//$
"Test"
   $tcmdl = <<<#>>>
cmd01
cmd02
cmd03
cmd04
cmd05
#>>>;

   explode($tcmdlxa, $tcmdl, <crlf>);                              // put into an array
   $tcmdlxx    = implode($tcmdlxa, , ', ');                        // to tokenlist again, sep=', '
   $agcmdl[0]  = $tcmdlxx;                                         //! Array Group CMD List(0) = ALL CMDS
   $agcmdlf[0] = $tcmdlxx;                                         //! Array Group CMD List Found(0) = "
   UnSet    $tcmdlxa, $tcmdlxx;                                    // were only temp!

   $agnr[0]   = 0;                                                 //! Array GNR(0) = 0
   $agtit[0]   = "ALL CMDS";                                       //! Array G TITle = "ALL CMDS"
   $ccmdgnr   = $agnr[0];                                          //! dflt: Curr CMD Grp NR = 0
   $ccmdgt   =   $agtit[0];                                        //! dflt: Curr CMD Grp Title = "ALL CMDS"
      Text  "§grpnbr = 0, §agnr[0] = '$agnr[0]', §agtit[0] = '$agtit[0]'.";
   
   step; // to stop it  :-)
Seems more elements of different arrays will be wrong! But I think this shows the reason exact enough?

Had expected it to be more complicated (for me) :ninja:
Lets see how it's for you. Seems to be some pointers or so?
Win11 Pro 223H2 Gerrman

admin
Site Admin
Posts: 60643
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Error on arrays while creating or assigning some vars

Post by admin »

Sorry, no time to try to understand your post or your script. :P Please narrow it down to the bug (if there is one).

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Error on arrays while creating or assigning some vars

Post by PeterH »

In short?
After an unset-stmt (on an array and a string) defining array-vars by setting an element, or just setting elements, change (these or other) elements.
Without the unset they don't.
Win11 Pro 223H2 Gerrman

admin
Site Admin
Posts: 60643
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Error on arrays while creating or assigning some vars

Post by admin »

Got it! Good find! :tup: Fixed in next beta.

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Error on arrays while creating or assigning some vars

Post by PeterH »

Thanks! Saw the beta :appl:

Will test this evening...
Win11 Pro 223H2 Gerrman

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: [fixed] Error on arrays while creating or assigning some vars

Post by PeterH »

OK: *have* tested. Result: fixed :tup:
Win11 Pro 223H2 Gerrman

Post Reply