Undefined element of (assoc) array shown as 'string'

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%

Undefined element of (assoc) array shown as 'string'

Post by PeterH »

I'd expect vartype() to show an undefined element of an (associative) array as 'undefined'.
But it's shown as 'string'. To repro (see following script):

- Array $GAf[] is undefined
- Define it by setting one element "c" to 0
- now check any other (non-existing) element by VarType(): it's shown as "string"
- (should be "undefined", I think)

- set a yet undefiined element to 3
- VarType() now shows it correct as "int".

Result: an undefined element can't be recognized!

(Sample script, made from a real world script. There the array is Global - but that makes no difference.)

Code: Select all

//§
"Test"
   step;
   $GAf["c"] = 0;                   // define $GAf[] by setting 1 element
   $exist  = VarType($GAf["abc"]);  // is undefined, but shown as "string"
   $exist  = VarType($GAf[11]);     // is undefined, also shown as "string"

   $GAf["abc"] = 3;                 // define it by setting to 3
   $exist  = VarType($GAf["abc"]);  // now correct shown as "int"

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

Re: Undefined element of (assoc) array shown as 'string'

Post by admin »

Agreed! :tup: Next beta. :cup:

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

Re: Undefined element of (assoc) array shown as 'string'

Post by PeterH »

:tup:

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

Re: Undefined element of (assoc) array shown as 'string'

Post by PeterH »

Prev :tup: was for implementing, now a :tup: for testing.

Is it so that I alone found > 80% of bugs with arrays? :whistle:

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

Re: Undefined element of (assoc) array shown as 'string'

Post by admin »

Looks like it, arrayzor head!

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

Re: Undefined element of (assoc) array shown as 'string'

Post by PeterH »

:roll:

Post Reply