PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Associative Arrays  (Read 560 times)

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Associative Arrays
« on: October 17, 2022, 11:06:23 AM »
Hello All,

If I have a small associative array of items like this
INSTALL_ITEM_ARRAY["INS1"]=1
INSTALL_ITEM_ARRAY["INS2"]=1
INSTALL_ITEM_ARRAY["INS3"]=1

 If I check to see if item is in the array it adds that item to array with a value of 0.
Question -> Is there a way i can check the array without it adding it to array. Is this taking up room in memory ...
if i'm checking a few million invoices lines - i dont want to run into an error 31

I know i can use a memory file but the associative array is quite convenient.

thanks

jeff

Mike King

  • Diamond Member
  • *****
  • Posts: 3811
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Associative Arrays
« Reply #1 on: October 17, 2022, 11:25:49 AM »
Have you tried

X = DIM(INDEX INSTALL_ITEM_ARRAY["INSx"])

The DIM(INDEX) will return you the index for the selected item or zero if not in the array.  It will not add the elelment.

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Re: Associative Arrays
« Reply #2 on: October 17, 2022, 11:32:11 AM »
Thanks Mike
that is exactly what i am looking for.

jeff