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

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

[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.

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

Re: Error on arrays while creating or assigning some vars

Post by admin »

Can't you narrow this down?

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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: )

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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?

admin
Site Admin
Posts: 66560
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @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: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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.

admin
Site Admin
Posts: 66560
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @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: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Error on arrays while creating or assigning some vars

Post by PeterH »

Thanks! Saw the beta :appl:

Will test this evening...

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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

Post by PeterH »

OK: *have* tested. Result: fixed :tup:

Post Reply